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

pub struct Schema { /* fields omitted */ }

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

impl Schema[src]

pub fn from_doc(doc: &Document) -> Result<Self>[src]

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

pub fn hash(&self) -> &Hash[src]

Get the hash of this schema.

pub fn validate_new_doc(&self, doc: NewDocument) -> Result<Document>[src]

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.

pub fn encode_doc(&self, doc: Document) -> Result<(Hash, Vec<u8>)>[src]

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

pub fn decode_doc(&self, doc: Vec<u8>) -> Result<Document>[src]

Decode a document that uses this schema.

pub fn trusted_decode_doc(&self, doc: Vec<u8>) -> Result<Document>[src]

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>)>>
[src]

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>)>>
[src]

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>>
[src]

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>
[src]

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.

pub fn encode_query(&self, query: NewQuery) -> Result<Vec<u8>>[src]

pub fn decode_query(&self, query: Vec<u8>) -> Result<Query>[src]

Auto Trait Implementations

impl RefUnwindSafe for Schema

impl Send for Schema

impl Sync for Schema

impl Unpin for Schema

impl UnwindSafe for Schema

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,