pub struct SharedVersionedChain<T: Copy + 'static> { /* private fields */ }Implementations§
Sourcepub fn create(
path: impl AsRef<Path>,
capacity: usize,
) -> Result<Self, ChainError>
pub fn create( path: impl AsRef<Path>, capacity: usize, ) -> Result<Self, ChainError>
Obtain the chain at path, initializing an empty one if the
path does not yet exist and attaching to it if it does.
Attaching leaves live nodes, the head and the free list in
place; a chain built with a different capacity or payload type
is a LayoutMismatch. reset reinitializes.
Sourcepub fn reset(
path: impl AsRef<Path>,
capacity: usize,
) -> Result<Self, ChainError>
pub fn reset( path: impl AsRef<Path>, capacity: usize, ) -> Result<Self, ChainError>
Truncate the chain at path and initialize an empty one,
discarding every node live peers hold. For a caller that knows
it owns the path.
pub fn open( path: impl AsRef<Path>, expected_capacity: usize, ) -> Result<Self, ChainError>
pub fn capacity(&self) -> usize
Sourcepub fn clear(&self)
pub fn clear(&self)
Reset to empty: head -> NIL, live_count -> 0, free list rebuilt
to contain all slots. Stale version values referring to old
snapshots become invalid. Not thread-safe with concurrent
push/read from other threads.
pub fn header(&self) -> &ChainHeader
Sourcepub fn push(&self, version: u64, value: T) -> Result<(), ChainError>
pub fn push(&self, version: u64, value: T) -> Result<(), ChainError>
Push a new version at the head. version must be strictly
greater than the current head’s version (MVCC invariant).
Sourcepub fn read_at(&self, snapshot_version: u64) -> Option<T>
pub fn read_at(&self, snapshot_version: u64) -> Option<T>
Read the value visible at snapshot_version. Walks back from
head through the chain until a node with version <= snapshot
is found. Returns None if no such version exists.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn flush(&self) -> Result<(), ChainError>
Sourcepub fn flush_async(&self) -> Result<(), ChainError>
pub fn flush_async(&self) -> Result<(), ChainError>
Non-blocking flush: schedules a writeback via the OS. Note: Windows is only partially async (sync to page cache, not to disk).