asphalt.serialization.object_codec
- class asphalt.serialization.object_codec.DefaultCustomTypeCodec(type_key='__type__', state_key='state')
Bases:
Generic[T_Serializer],CustomTypeCodec[T_Serializer]Provides default wrappers for implementing
CustomTypeCodec.- Variables:
serializer (CustomizableSerializer) – the associated serializer
- Parameters:
- default_decoder(obj)
Handle a dict that might contain a wrapped state for a custom type.
- Return type:
- unwrap_state_dict(obj)
Unwrap a marshalled state previously wrapped using
wrap_state_dict().
- wrap_state_dict(typename, state)
Wrap the marshalled state in a dictionary.
The returned dictionary has two keys, corresponding to the
type_keyandstate_keyoptions. The former holds the type name and the latter holds the marshalled state.- Parameters:
typename – registered name of the custom type
state – the marshalled state of the object
- Returns:
an object serializable by the serializer