Module fog_pack::document

source ·
Expand description

Serialized data optionally adhering to a schema.

Documents are created by taking a serializable struct and calling NewDocument::new with it, along with an optional Hash of the schema the document will adhere to. Once created, it can be signed and the compression setting can be chosen. To create a complete, verified document, it must be passed to NoSchema or a Schema, as appropriate.

In addition to direct creation, two additional builder structs are available. VecDocumentBuilder can be used to take a long iterator and create many documents that are arrays of the serialized items in the iterator. The builder produces documents 512 kiB in size or lower. This is useful for serializing large lists that don’t fit in the Document maximum size limit of 1 MiB. AsyncVecDocumentBuilder does the same, but for asynchronous Streams.

Structs

Functions

  • Attempt to get the schema for a raw document. Fails if the raw byte slice doesn’t conform to the right format, or if the hash is invalid.