serializer
Classes:
-
SerializedData–The serialized representation of a value.
-
SerializedDataStream–The serialized representation of a stream of values.
-
Serializer–A protocol for serializing/deserializing values.
-
StreamSerializer–A protocol for serializing/deserializing streams of values.
SerializedData
The serialized representation of a value.
Attributes:
-
config(NotRequired[C]) –Additional configuration for the serializer, if any.
-
content_encoding(str | None) –The encoding of the data.
-
content_type(str) –The MIME type of the data.
-
data(bytes) –The serialized data.
config
instance-attribute
config: NotRequired[C]
Additional configuration for the serializer, if any.
SerializedDataStream
The serialized representation of a stream of values.
Attributes:
-
config(NotRequired[C]) –Additional configuration for the serializer, if any.
-
content_encoding(str | None) –The encoding of the data.
-
content_type(str) –The MIME type of the data.
-
data_stream(AsyncGenerator[bytes]) –The serialized data stream.
config
instance-attribute
config: NotRequired[C]
Additional configuration for the serializer, if any.
Serializer
Bases: _BaseSerializer[T, C], Component
A protocol for serializing/deserializing values.
Methods:
-
deserialize_config–Deserialize the configuration from a JSON string.
-
deserialize_data–Deserialize the given value.
-
serialize_config–Serialize the configuration to a JSON string.
-
serialize_data–Serialize the given value.
Attributes:
-
content_types(tuple[str, ...]) –The content types that the serializer uses.
-
name(LiteralString) –The globally unique name of the component.
-
types(tuple[type[T], ...]) –The types that the serializer can handle
content_types
class-attribute
instance-attribute
The content types that the serializer uses.
Used to get serializers by content type in the registry.
types
class-attribute
instance-attribute
The types that the serializer can handle
Used for type inference in the registry.
deserialize_config
deserialize_config(config: str) -> C
Deserialize the configuration from a JSON string.
deserialize_data
abstractmethod
deserialize_data(content: SerializedData[C]) -> T
Deserialize the given value.
serialize_data
abstractmethod
serialize_data(value: T) -> SerializedData[C]
Serialize the given value.
StreamSerializer
Bases: _BaseSerializer[T, C], Component
A protocol for serializing/deserializing streams of values.
Methods:
-
deserialize_config–Deserialize the configuration from a JSON string.
-
deserialize_data_stream–Deserialize the given stream.
-
serialize_config–Serialize the configuration to a JSON string.
-
serialize_data_stream–Serialize the given stream.
Attributes:
-
content_types(tuple[str, ...]) –The content types that the serializer uses.
-
name(LiteralString) –The globally unique name of the component.
-
types(tuple[type[T], ...]) –The types that the serializer can handle
content_types
class-attribute
instance-attribute
The content types that the serializer uses.
Used to get serializers by content type in the registry.
types
class-attribute
instance-attribute
The types that the serializer can handle
Used for type inference in the registry.
deserialize_config
deserialize_config(config: str) -> C
Deserialize the configuration from a JSON string.
deserialize_data_stream
abstractmethod
deserialize_data_stream(
content: SerializedDataStream[C],
) -> AsyncGenerator[T]
Deserialize the given stream.
serialize_data_stream
abstractmethod
serialize_data_stream(
stream: AsyncIterable[T],
) -> SerializedDataStream[C]
Serialize the given stream.