SlySerialize.abc#
Base classes for loaders, unloaders, and converters.
Classes
Deserializes one type or group of types asynchronously |
|
Both serializes and deserializes one type or group of types T to and from Domain |
|
|
Deserializes one type or group of types |
|
State for deserialization and recursion |
|
Serializes one type or group of types |
|
State for serialization and recursion |
- class SlySerialize.abc.LoadingContext(converter: Loader[Domain, T], only_sync: bool)#
Bases:
Generic
[Domain
,T
]State for deserialization and recursion
- type_vars: dict[str, type]#
- parent_type: type | None#
- only_sync: bool#
- des(value: Domain, cls: type[T]) T #
- class SlySerialize.abc.UnloadingContext(converter: Unloader[Domain, T])#
Bases:
Generic
[Domain
,T
]State for serialization and recursion
- ser(value: T) Domain #
- class SlySerialize.abc.Unloader#
Bases:
ABC
,Generic
[Domain
,T
]Serializes one type or group of types
- abstractmethod can_unload(cls: type) bool #
Whether this converter should be used to serialize the given type
- abstractmethod ser(ctx: UnloadingContext[Domain, Any], value: T) Domain #
Convert a value to a domain-compatible type.
Called only if can_unload returned True for type(value).
- class SlySerialize.abc.Loader#
Bases:
ABC
,Generic
[Domain
,T
]Deserializes one type or group of types
- abstractmethod can_load(cls: type) bool #
Whether this converter should be used to deserialize the given type
- abstractmethod des(ctx: LoadingContext[Domain, Any], value: Domain, cls: type[T]) T #
Convert a domain value to the specified type.
Called only if can_load returned True for cls.
- class SlySerialize.abc.Converter#
Bases:
Unloader
[Domain
,T
],Loader
[Domain
,T
]Both serializes and deserializes one type or group of types T to and from Domain
- abstractmethod can_load(cls: type) bool #
Whether this converter should be used to deserialize the given type
- abstractmethod can_unload(cls: type) bool #
Whether this converter should be used to serialize the given type
- abstractmethod des(ctx: LoadingContext[Domain, Any], value: Domain, cls: type[T]) T #
Convert a domain value to the specified type.
Called only if can_load returned True for cls.
- abstractmethod ser(ctx: UnloadingContext[Domain, Any], value: T) Domain #
Convert a value to a domain-compatible type.
Called only if can_unload returned True for type(value).
- class SlySerialize.abc.AsyncLoader#
Bases:
Loader
[Domain
,T
]Deserializes one type or group of types asynchronously
- abstractmethod can_load(cls: type) bool #
Whether this converter should be used to deserialize the given type
- abstractmethod await des(ctx: LoadingContext[Domain, Any], value: Domain, cls: type) T #
Convert a domain value to the specified type.
Called only if can_load returned True for cls.