Merge branch 'master_gh'

This commit is contained in:
Georg K
2023-12-13 14:05:14 +03:00
4 changed files with 62 additions and 33 deletions

View File

@@ -1868,6 +1868,23 @@ class Message(ABC):
Message.__annotations__ = {} # HACK to avoid typing.get_type_hints breaking :)
# monkey patch (de-)serialization functions of class `Message`
# with functions from `betterproto-rust-codec` if available
try:
import betterproto_rust_codec
def __parse_patch(self: T, data: bytes) -> T:
betterproto_rust_codec.deserialize(self, data)
return self
def __bytes_patch(self) -> bytes:
return betterproto_rust_codec.serialize(self)
Message.parse = __parse_patch
Message.__bytes__ = __bytes_patch
except ModuleNotFoundError:
pass
def serialized_on_wire(message: Message) -> bool:
"""