storage
Classes:
-
Digest–A digest describing serialized data.
-
GetStreamDigest–A protocol for getting the digest of stream content.
-
Storage–A protocol for storing and retrieving data.
-
StreamDigest–A digest describing a stream of serialized data.
Digest
Bases: TypedDict
A digest describing serialized data.
Attributes:
-
content_encoding(str | None) –The encoding of the data.
-
content_hash(str) –The hash of the data.
-
content_hash_algorithm(str) –The algorithm used to hash the data.
-
content_size(int) –The size of the data in bytes.
-
content_type(str) –The MIME type of the data.
content_hash_algorithm
instance-attribute
content_hash_algorithm: str
The algorithm used to hash the data.
GetStreamDigest
Storage
Bases: Generic[C], Component
A protocol for storing and retrieving data.
Methods:
-
deserialize_config–Deserialize the configuration from a JSON string.
-
read_data–Load data using the given information.
-
read_data_stream–Load a stream of data using the given information.
-
serialize_config–Serialize the configuration to a JSON string.
-
write_data–Save the given data and return information that can be used to retrieve it.
-
write_data_stream–Save the given stream and return information that can be used to retrieve it.
Attributes:
-
name(LiteralString) –The globally unique name of the component.
deserialize_config
deserialize_config(config: str) -> C
Deserialize the configuration from a JSON string.
read_data_stream
abstractmethod
read_data_stream(info: C) -> AsyncGenerator[bytes]
Load a stream of data using the given information.
write_data
abstractmethod
async
write_data_stream
abstractmethod
async
write_data_stream(
data_stream: AsyncIterable[bytes],
get_digest: GetStreamDigest,
tags: TagMap,
) -> C
Save the given stream and return information that can be used to retrieve it.
Parameters:
-
(data_streamAsyncIterable[bytes]) –An async iterable that yields chunks of data to save.
-
(get_digestGetStreamDigest) –Function returning the digest of the stream content.
-
(tagsTagMap) –Tags from the user or unpacker that describe the data.
StreamDigest
Bases: Digest
A digest describing a stream of serialized data.
Attributes:
-
content_encoding(str | None) –The encoding of the data.
-
content_hash(str) –The hash of the data.
-
content_hash_algorithm(str) –The algorithm used to hash the data.
-
content_size(int) –The size of the data in bytes.
-
content_type(str) –The MIME type of the data.
-
is_complete(bool) –A flag indicating whether the stream has been read in full.