Something went wrong. Try again.
A public mirror for the whole atmosphere hubble.microcosm.blue
Something went wrong. Try again.
608 B · 25 lines
Rust
at main
1234567891011121314151617181920212223242526//! 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<B: AsRef<[u8]>, S: BuildHasher> Blocks for HashMap<Cid, B, S> { fn get(&self, cid: &Cid) -> Option<&[u8]> { HashMap::get(self, cid).map(AsRef::as_ref) }}
impl<T: Blocks + ?Sized> Blocks for &T { fn get(&self, cid: &Cid) -> Option<&[u8]> { (**self).get(cid) }}