b.s.p._StatefulDecoder(object) : class documentation

Part of bzrlib.smart.protocol View In Hierarchy

Known subclasses: bzrlib.smart.protocol.ChunkedBodyDecoder, bzrlib.smart.protocol.LengthPrefixedBodyDecoder, bzrlib.smart.protocol.ProtocolThreeDecoder

Base class for writing state machines to decode byte streams.

Subclasses should provide a self.state_accept attribute that accepts bytes and, if appropriate, updates self.state_accept to a different function. accept_bytes will call state_accept as often as necessary to make sure the state machine has progressed as far as possible before it returns.

See ProtocolThreeDecoder for an example subclass.

Method __init__ Undocumented
Method accept_bytes Decode as much of bytes as possible.
Method _get_in_buffer Undocumented
Method _get_in_bytes Grab X bytes from the input_buffer.
Method _set_in_buffer Undocumented
def __init__(self):
Undocumented
def _get_in_buffer(self):
Undocumented
def _get_in_bytes(self, count):
Grab X bytes from the input_buffer.

Callers should have already checked that self._in_buffer_len is > count. Note, this does not consume the bytes from the buffer. The caller will still need to call _get_in_buffer() and then _set_in_buffer() if they actually need to consume the bytes.

def _set_in_buffer(self, new_buf):
Undocumented
def accept_bytes(self, bytes):
Decode as much of bytes as possible.

If 'bytes' contains too much data it will be appended to self.unused_data.

finished_reading will be set when no more data is required. Further data will be appended to self.unused_data.

API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.