Skip to content

msgpack

Classes:

Attributes:

MSG_PACK_TYPES module-attribute

MSG_PACK_TYPES = (
    int,
    str,
    float,
    bool,
    type(None),
    dict,
    list,
)

The types that can be serialized to the MessagePack format.

MsgPackType module-attribute

MsgPackType = (
    Any
    | int
    | str
    | float
    | bool
    | dict[int | str | float | bool | None, "MsgPackType"]
    | list["MsgPackType"]
    | None
)

A type alias for MessagePack data.

msgpack_serializer module-attribute

msgpack_serializer = MsgPackSerializer()

MsgPackSerializer with default settings.

msgpack_stream_serializer module-attribute

msgpack_stream_serializer = MsgPackStreamSerializer()

MsgPackStreamSerializer with default settings.

MsgPackSerializer

MsgPackSerializer(
    *,
    packer: Callable[[], Packer] = Packer,
    unpacker: Callable[[], Unpacker] = Unpacker
)

Bases: _MsgPackBase, Serializer[MsgPackType]

A serializer for MessagePack data.

Methods:

Attributes:

content_types class-attribute instance-attribute

content_types: tuple[str, ...] = ()

The content types that the serializer uses.

Used to get serializers by content type in the registry.

deserialize_config

deserialize_config(config: str) -> C

Deserialize the configuration from a JSON string.

deserialize_data

deserialize_data(content: SerializedData) -> MsgPackType

Deserialize the given MessagePack data.

serialize_config

serialize_config(config: C) -> str

Serialize the configuration to a JSON string.

serialize_data

serialize_data(value: MsgPackType) -> SerializedData

Serialize the given value to MessagePack.

MsgPackStreamSerializer

MsgPackStreamSerializer(
    *,
    packer: Callable[[], Packer] = Packer,
    unpacker: Callable[[], Unpacker] = Unpacker
)

Bases: _MsgPackBase, StreamSerializer[MsgPackType]

A serializer for MessagePack data.

Methods:

Attributes:

content_types class-attribute instance-attribute

content_types: tuple[str, ...] = ()

The content types that the serializer uses.

Used to get serializers by content type in the registry.

deserialize_config

deserialize_config(config: str) -> C

Deserialize the configuration from a JSON string.

deserialize_data_stream

deserialize_data_stream(
    content: SerializedDataStream,
) -> AsyncGenerator[MsgPackType]

Deserialize the given stream of MessagePack data.

dump_data

dump_data(value: Iterable[MsgPackType]) -> SerializedData

Serialize the given value to MessagePack.

load_data

load_data(content: SerializedData) -> list[MsgPackType]

Deserialize the given MessagePack data.

serialize_config

serialize_config(config: C) -> str

Serialize the configuration to a JSON string.

serialize_data_stream

serialize_data_stream(
    stream: AsyncIterable[MsgPackType],
) -> SerializedDataStream

Serialize the given stream of MessagePack data.