pub struct FsIndexStore { /* private fields */ }Expand description
The reference index substrate: one file per node under <root>/index.
Layout: <root>/index/<aa>/<bb>/<64-hex> where aa/bb are the first two
bytes of the id in hex. Writes are atomic (tmp -> fsync -> rename); reads are
hash-verified by FsIndexStore::get.
Implementations§
Source§impl FsIndexStore
impl FsIndexStore
Sourcepub fn open(root: impl AsRef<Path>) -> Result<Self>
pub fn open(root: impl AsRef<Path>) -> Result<Self>
Open (creating if needed) an index store rooted at root, using
root/index, with a fresh, private I/O counter set.
Sourcepub fn open_with_io(root: impl AsRef<Path>, io: IoCounters) -> Result<Self>
pub fn open_with_io(root: impl AsRef<Path>, io: IoCounters) -> Result<Self>
Open an index store that accounts every node read against io.
Sourcepub fn put(&mut self, canonical: &[u8]) -> Result<NodeId>
pub fn put(&mut self, canonical: &[u8]) -> Result<NodeId>
Store one canonical node, returning its content id. Idempotent and atomic.
Sourcepub fn get(&self, id: &NodeId) -> Result<Vec<u8>>
pub fn get(&self, id: &NodeId) -> Result<Vec<u8>>
Fetch a node, verifying NodeId::of_node(bytes) == id.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for FsIndexStore
impl !Send for FsIndexStore
impl !Sync for FsIndexStore
impl !UnwindSafe for FsIndexStore
impl Freeze for FsIndexStore
impl Unpin for FsIndexStore
impl UnsafeUnpin for FsIndexStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more