Function bao::decode::hash_from_encoded_nostd [−][src]
pub fn hash_from_encoded_nostd<F, E>(read_exact_fn: F) -> Result<Hash, E> where
F: FnMut(&mut [u8]) -> Result<(), E>,
Given a combined encoding, quickly determine the root hash by reading just the root node.
The read_exact_fn
callback will be called exactly twice.
Example
let (hash1, encoded) = bao::encode::encode_to_vec(b"foobar"); let mut reader = &*encoded; let hash2 = bao::decode::hash_from_encoded_nostd(|buf| { let take = buf.len(); buf.copy_from_slice(&reader[..take]); reader = &reader[take..]; Ok::<(), ()>(()) }).unwrap(); assert_eq!(hash1, hash2);