Add support for bypassing pre-packed data

This commit is contained in:
Marco Ribeiro 2026-02-13 11:04:04 -03:00
parent f9806368ae
commit e4ec35b7d3
4 changed files with 21 additions and 3 deletions

View file

@ -16,6 +16,19 @@ class ExtType(namedtuple("ExtType", "code data")):
return super().__new__(cls, code, data)
class Bypass:
"""Bypass is a placeholder class to skip serialization and pass the bytes value as is."""
__slots__ = ["data"]
def __init__(self, data):
if isinstance(data, bytes):
self.data = data
else:
self.data = memoryview(data).tobytes()
class Timestamp:
"""Timestamp represents the Timestamp extension type in msgpack.