[][src]Struct fog_pack::NoSchema

pub struct NoSchema { /* fields omitted */ }

An encoder/decoder for when no Schema is being used.

NoSchema is used to encode/decode both Documents & Entries when there is no associated Schema in use. It shouldn't be used with any Document that has a schema, or with any Entry whose parent Document has a schema.

Implementations

impl NoSchema[src]

pub fn new() -> NoSchema[src]

Create a new NoSchema instance.

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

Encode the document and write it to a byte vector. By default, compression with the zstd default will be used, which may be overridden by the Document.

Errors

Fails if the Document has an associated schema.

Panics

Panics if the underlying zstd calls return an error, which shouldn't be possible with the way they are used in this library.

pub fn trusted_decode_doc(
    &mut self,
    buf: &mut &[u8],
    hash: Option<Hash>
) -> Result<Document>
[src]

Read a document from a byte slice, trusting the origin of the slice and doing as few checks as possible when decoding. It fails if there isn't a valid fogpack value, the compression isn't recognized/is invalid, the slice terminates early, or if the document is using a compression schema or compression method requiring a schema.

Rather than compute the hash, the document hash can optionally be provided. If integrity checking is desired, provide no hash and compare the expected hash with the hash of the resulting document.

The only time this should be used is if the byte slice is coming from a well-trusted location, like an internal database.

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

Read a document from a byte slice, performing a full set of validation checks when decoding. Success guarantees that the resulting Document is valid, and as such, this can be used with untrusted inputs.

Validation checking means this will fail if:

  • The data is corrupted or incomplete
  • The data isn't valid fogpack
  • The compression is invalid or expands to larger than the maximum allowed size
  • The compression requires the schema to decode
  • The decompressed document has an associated schema hash
  • Any of the attached signatures are invalid

Auto Trait Implementations

impl RefUnwindSafe for NoSchema

impl Send for NoSchema

impl !Sync for NoSchema

impl Unpin for NoSchema

impl UnwindSafe for NoSchema

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, 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.