feat(trezorlib): allow encoding of protobuf messages without wire type

[no changelog]
M1nd3r/thp1
M1nd3r 1 month ago
parent ff859be2c3
commit c8e4fd7fba

@ -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]

Loading…
Cancel
Save