Struct fog_pack::schema::Schema[][src]

pub struct Schema { /* fields omitted */ }
Expand description

A Schema, which can be used to encode/decode a document or entry, while verifying its contents.

Schema are decoded from a correctly formatted Document that describes the format of other documents and their associated entries. They also include recommended compression settings for documents & entries adhering to them, which may include compression dictionaries.

A schema must come from a Document. To create one directly, use the SchemaBuilder, then decode the resulting Document into a schema.

Implementations

Attempt to create a schema from a given document. Fails if the document isn’t a schema.

Get the hash of this schema.

Validate a NewDocument, turning it into a Document. Fails if the document doesn’t use this schema, or if it doesn’t meet this schema’s requirements.

Encode a Document, returning the resulting Document’s hash and fully encoded format. Fails if the document doesn’t use this schema.

Decode a document that uses this schema.

Decode a Document, skipping any checks of the data. This should only be run when the raw document has definitely been passed through validation before, i.e. if it is stored in a local database after going through encode_doc.

pub fn encode_new_entry(
    &self,
    entry: NewEntry
) -> Result<DataChecklist<'_, (Hash, Vec<u8>)>>

Encode a NewEntry, returning the resulting Entry’s hash and fully encoded format.
Fails if the entry key isn’t in the schema, or it doesn’t meet the requirements. The resulting entry is stored in a DataChecklist that must be iterated over in order to finish verification and get the resulting data.

pub fn encode_entry(
    &self,
    entry: Entry
) -> Result<DataChecklist<'_, (Hash, Vec<u8>)>>

Encode an Entry, returning the resulting Entry’s hash and fully encoded format.
Fails if the entry key isn’t in the schema, or it doesn’t meet the requirements. The resulting entry is stored in a DataChecklist that must be iterated over in order to finish verification and get the resulting data.

pub fn decode_entry(
    &self,
    entry: Vec<u8>,
    key: &str,
    parent: &Hash
) -> Result<DataChecklist<'_, Entry>>

Decode an entry, given the key and parent Hash. Result is in a DataChecklist that must be iterated over in order to finish verification and get the resulting Entry.

pub fn trusted_decode_entry(
    &self,
    entry: Vec<u8>,
    key: &str,
    parent: &Hash
) -> Result<Entry>

Decode a Entry, skipping any checks of the data. This should only be run when the raw entry has definitely been passed through validation before, i.e. if it is stored in a local database after going through encode_entry or encode_new_entry.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.