|
|
|
@ -68,6 +68,16 @@ class ProtobufMapping:
|
|
|
|
|
protobuf.dump_message(buf, msg)
|
|
|
|
|
return wire_type, buf.getvalue()
|
|
|
|
|
|
|
|
|
|
def encode_without_wire_type(self, msg: protobuf.MessageType) -> bytes:
|
|
|
|
|
"""Serialize a Python protobuf class.
|
|
|
|
|
|
|
|
|
|
Returns the byte representation of the protobuf message.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
buf = io.BytesIO()
|
|
|
|
|
protobuf.dump_message(buf, msg)
|
|
|
|
|
return buf.getvalue()
|
|
|
|
|
|
|
|
|
|
def decode(self, msg_wire_type: int, msg_bytes: bytes) -> protobuf.MessageType:
|
|
|
|
|
"""Deserialize a protobuf message into a Python class."""
|
|
|
|
|
cls = self.type_to_class[msg_wire_type]
|
|
|
|
|