# Path: zoonado/protocol/request.py
# class Request(Part):
#     """
#     Returns a bytesring representation of the request instance.
# 
#     # TODO(wglass): specify how xid and type preamble goes in
# 
#     Since this is a ``Part`` subclass the rest is a matter of
#     appending the result of a ``render()`` call.
#     """
#     opcode = None
#     special_xid = None
#     writes_data = False
# 
#     def serialize(self, xid=None):
#         buff = BytesIO()
# 
#         formats = []
#         data = []
# 
#         if xid is not None:
#             formats.append(Int.fmt)
#             data.append(xid)
# 
#         if self.opcode:
#             formats.append(Int.fmt)
#             data.append(self.opcode)
# 
#         payload_format, payload_data = self.render()
#         formats.append(payload_format)
#         data.extend(payload_data)
# 
#         buff.write(struct.pack("!" + "".join(formats), *data))
# 
#         return buff.getvalue()
# 
# Path: zoonado/protocol/response.py
# class Response(Part):
#     """
#     Base class for all operation response classes.
# 
#     A simple class, has only an ``opcode`` attribute expected to be defined by
#     subclasses, and a `deserialize()` classmethod.
#     """
#     opcode = None
# 
#     @classmethod
#     def deserialize(cls, raw_bytes):
#         """
#         Deserializes the given raw bytes into an instance.
# 
#         Since this is a subclass of ``Part`` but a top-level one (i.e. no other
#         subclass of ``Part`` would have a ``Response`` as a part) this merely
#         has to parse the raw bytes and discard the resulting offset.
#         """
#         instance, _ = cls.parse(raw_bytes, offset=0)
# 
#         return instance
# 
# Path: zoonado/protocol/primitives.py
# class Int(Primitive):
#     """
#     Represents an 32-bit signed integer.
#     """
#     fmt = "i"
# 
# class Long(Primitive):
#     """
#     Represents an 64-bit signed integer.
#     """
#     fmt = "q"
# 
# class Vector(Primitive):
#     """
#     Represents an array of any arbitrary `Primitive` or ``Part``.
# 
#     Not used directly but rather by its ``of()`` classmethod to denote an
#     ``Vector.of(<something>)``.
#     """
#     item_class = None
# 
#     @classmethod
#     def of(cls, part_class):
#         """
#         Creates a new class with the ``item_class`` attribute properly set.
#         """
#         copy = type(
#             str("VectorOf%s" % part_class.__name__),
#             cls.__bases__, dict(cls.__dict__)
#         )
#         copy.item_class = part_class
# 
#         return copy
# 
#     def render(self):
#         """
#         Creates a composite ``struct`` format and the data to render with it.
# 
#         The format and data are prefixed with a 32-bit integer denoting the
#         number of elements, after which each of the items in the array value
#         are ``render()``-ed and added to the format and data as well.
#         """
#         value = self.value
#         if value is None:
#             value = []
# 
#         fmt = [Int.fmt]
#         data = [len(value)]
# 
#         for item_value in value:
#             if issubclass(self.item_class, Primitive):
#                 item = self.item_class(item_value)
#             else:
#                 item = item_value
# 
#             item_format, item_data = item.render()
#             fmt.extend(item_format)
#             data.extend(item_data)
# 
#         return "".join(fmt), data
# 
#     @classmethod
#     def parse(cls, buff, offset):
#         """
#         Parses a raw buffer at offset and returns the resulting array value.
# 
#         Starts off by `parse()`-ing the 32-bit element count, followed by
#         parsing items out of the buffer "count" times.
#         """
#         count, offset = Int.parse(buff, offset)
# 
#         values = []
#         for _ in range(count):
#             value, new_offset = cls.item_class.parse(buff, offset)
# 
#             values.append(value)
#             offset = new_offset
# 
#         return values, offset
# 
#     def __str__(self):
#         return "%s[%s]" % (
#             self.item_class.__name__, ", ".join(map(str, self.value))
#         )
# 
# class UString(VariablePrimitive):
#     """
#     Represents a unicode string value, length denoted by a 32-bit integer.
#     """
#     size_primitive = Int
# 
#     def render_value(self, value):
#         return value.encode("utf8")
# 
#     @classmethod
#     def parse_value(cls, value):
#         return value.decode("utf8")
# 
#     def __str__(self):
#         return self.value


from .request import Request
from .response import Response
from .primitives import Int, Long, Vector, UString
    SESSION_EXPIRED = -112

    parts = (
        ("type", Int),
        ("state", Int),
        ("path", UString),
    )


class SetWatchesRequest(Request):
    """
    """
    opcode = 101

    parts = (
        ("relative_zxid", Long),
        ("data_watches", Vector.of(UString)),
        ("exist_watches", Vector.of(UString)),
        ("child_watches", Vector.of(UString)),
    )


class SetWatchesResponse(Response):
    """
    """
    opcode = 101

    parts = ()



# Path: zoonado/protocol/request.py
# class Request(Part):
#     """
#     Returns a bytesring representation of the request instance.
# 
#     # TODO(wglass): specify how xid and type preamble goes in
# 
#     Since this is a ``Part`` subclass the rest is a matter of
#     appending the result of a ``render()`` call.
#     """
#     opcode = None
#     special_xid = None
#     writes_data = False
# 
#     def serialize(self, xid=None):
#         buff = BytesIO()
# 
#         formats = []
#         data = []
# 
#         if xid is not None:
#             formats.append(Int.fmt)
#             data.append(xid)
# 
#         if self.opcode:
#             formats.append(Int.fmt)
#             data.append(self.opcode)
# 
#         payload_format, payload_data = self.render()
#         formats.append(payload_format)
#         data.extend(payload_data)
# 
#         buff.write(struct.pack("!" + "".join(formats), *data))
# 
#         return buff.getvalue()
# 
# Path: zoonado/protocol/response.py
# class Response(Part):
#     """
#     Base class for all operation response classes.
# 
#     A simple class, has only an ``opcode`` attribute expected to be defined by
#     subclasses, and a `deserialize()` classmethod.
#     """
#     opcode = None
# 
#     @classmethod
#     def deserialize(cls, raw_bytes):
#         """
#         Deserializes the given raw bytes into an instance.
# 
#         Since this is a subclass of ``Part`` but a top-level one (i.e. no other
#         subclass of ``Part`` would have a ``Response`` as a part) this merely
#         has to parse the raw bytes and discard the resulting offset.
#         """
#         instance, _ = cls.parse(raw_bytes, offset=0)
# 
#         return instance
# 
# Path: zoonado/protocol/primitives.py
# class Int(Primitive):
#     """
#     Represents an 32-bit signed integer.
#     """
#     fmt = "i"
# 
# class Long(Primitive):
#     """
#     Represents an 64-bit signed integer.
#     """
#     fmt = "q"
# 
# class Vector(Primitive):
#     """
#     Represents an array of any arbitrary `Primitive` or ``Part``.
# 
#     Not used directly but rather by its ``of()`` classmethod to denote an
#     ``Vector.of(<something>)``.
#     """
#     item_class = None
# 
#     @classmethod
#     def of(cls, part_class):
#         """
#         Creates a new class with the ``item_class`` attribute properly set.
#         """
#         copy = type(
#             str("VectorOf%s" % part_class.__name__),
#             cls.__bases__, dict(cls.__dict__)
#         )
#         copy.item_class = part_class
# 
#         return copy
# 
#     def render(self):
#         """
#         Creates a composite ``struct`` format and the data to render with it.
# 
#         The format and data are prefixed with a 32-bit integer denoting the
#         number of elements, after which each of the items in the array value
#         are ``render()``-ed and added to the format and data as well.
#         """
#         value = self.value
#         if value is None:
#             value = []
# 
#         fmt = [Int.fmt]
#         data = [len(value)]
# 
#         for item_value in value:
#             if issubclass(self.item_class, Primitive):
#                 item = self.item_class(item_value)
#             else:
#                 item = item_value
# 
#             item_format, item_data = item.render()
#             fmt.extend(item_format)
#             data.extend(item_data)
# 
#         return "".join(fmt), data
# 
#     @classmethod
#     def parse(cls, buff, offset):
#         """
#         Parses a raw buffer at offset and returns the resulting array value.
# 
#         Starts off by `parse()`-ing the 32-bit element count, followed by
#         parsing items out of the buffer "count" times.
#         """
#         count, offset = Int.parse(buff, offset)
# 
#         values = []
#         for _ in range(count):
#             value, new_offset = cls.item_class.parse(buff, offset)
# 
#             values.append(value)
#             offset = new_offset
# 
#         return values, offset
# 
#     def __str__(self):
#         return "%s[%s]" % (
#             self.item_class.__name__, ", ".join(map(str, self.value))
#         )
# 
# class UString(VariablePrimitive):
#     """
#     Represents a unicode string value, length denoted by a 32-bit integer.
#     """
#     size_primitive = Int
# 
#     def render_value(self, value):
#         return value.encode("utf8")
# 
#     @classmethod
#     def parse_value(cls, value):
#         return value.decode("utf8")
# 
#     def __str__(self):
#         return self.value


# Path: zoonado/protocol/watches.py
from .request import Request
from .response import Response
from .primitives import Int, Long, Vector, UString

    SESSION_EXPIRED = -112

    parts = (
        ("type", Int),
        ("state", Int),
        ("path", UString),
    )


class SetWatchesRequest(Request):
    """
    """
    opcode = 101

    parts = (
        ("relative_zxid", Long),
        ("data_watches", Vector.of(UString)),
        ("exist_watches", Vector.of(UString)),
        ("child_watches", Vector.of(UString)),
    )


class SetWatchesResponse(Response):
    """
    """
    opcode = 101

    parts = ()



class CheckWatchesRequest(Request):