[−][src]Struct fog_pack::checklist::Checklist
A Checklist for validating an Entry.
The checklist can be iterated over, yielding a series of hashes and their associated
ChecklistItem. Passing an item to a schema along with the document referred to by the hash
allows it to be checked off the list. When all items have been checked off, calling
complete will return the contained data. This may be a Vec
Examples
Assuming there is a HashMap containing all documents, a function to encode and verify an entry could be:
fn encode_entry(e: Entry, schema: &mut Schema, db: &HashMap<Hash, Document>) -> Result<Vec<u8>, ()> { let mut checklist = schema.encode_entry(e).or(Err(()))?; // Fetch each document for verification, and fail if we don't have one for (h, item) in checklist.iter_mut() { if let Some(doc) = db.get(h) { schema.check_item(doc, item); } else { return Err(()); } } checklist.complete() }
Implementations
impl<T> Checklist<T>[src]
pub fn is_complete(&self) -> bool[src]
Check to see if the checklist is ready for completion.
pub fn complete(self) -> Result<T, ()>[src]
Complete the checklist and return the encoded Entry as a byte vector. Fails if the checklist was not completed.
pub fn iter(&self) -> Iter<Hash, ChecklistItem>[src]
Iterate over the checklist, yielding tuples of type (&Hash, &ChecklistItem).
pub fn iter_mut(&mut self) -> IterMut<Hash, ChecklistItem>[src]
Mutably iterate over the checklist, yielding tuples of type (&Hash, &mut ChecklistItem).
pub fn get(&self, h: &Hash) -> Option<&ChecklistItem>[src]
Fetch a specific checklist item by hash.
pub fn get_mut(&mut self, h: &Hash) -> Option<&mut ChecklistItem>[src]
Mutably fetch a specific checklist item by hash.
Auto Trait Implementations
impl<T> RefUnwindSafe for Checklist<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Checklist<T> where
T: Send,
T: Send,
impl<T> Sync for Checklist<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Checklist<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Checklist<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,