def decode(self, s: bytearray) -> None: """ Decode given bytearray s to this object. :param s: A bytearray with length at least `BYTES_LENGTH`. """ assert len(s) >= self.BYTES_LENGTH, bp.NotEnoughBytes() ctx = bp.ProcessContext(False, s) self.bp_processor().process(ctx, bp.NIL_DATA_INDEXER, self)
def encode(self) -> bytearray: """ Encode this object to bytearray. """ s = bytearray(self.BYTES_LENGTH) ctx = bp.ProcessContext(True, s) self.bp_processor().process(ctx, bp.NIL_DATA_INDEXER, self) return ctx.s