//! Where the tree reads its nodes from. use std::collections::HashMap; use std::hash::BuildHasher; use crate::cid::Cid; /// A (small) store of MST blocks from a partial CAR /// /// (small because we're talking about firehose commits.) pub trait Blocks { fn get(&self, cid: &Cid) -> Option<&[u8]>; } impl, S: BuildHasher> Blocks for HashMap { fn get(&self, cid: &Cid) -> Option<&[u8]> { HashMap::get(self, cid).map(AsRef::as_ref) } } impl Blocks for &T { fn get(&self, cid: &Cid) -> Option<&[u8]> { (**self).get(cid) } }