Skip to main content

SharedVersionedChain

Struct SharedVersionedChain 

Source
pub struct SharedVersionedChain<T: Copy + 'static> { /* private fields */ }

Implementations§

Source§

impl<T: Copy + 'static> SharedVersionedChain<T>

Source

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.

Source

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.

Source

pub fn open( path: impl AsRef<Path>, expected_capacity: usize, ) -> Result<Self, ChainError>

Source

pub fn capacity(&self) -> usize

Source

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.

Source

pub fn header(&self) -> &ChainHeader

Source

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).

Source

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.

Source

pub fn current(&self) -> Option<(u64, T)>

Latest (head) version + value, or None if empty.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn flush(&self) -> Result<(), ChainError>

Source

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).

Trait Implementations§

Source§

impl<T: Copy + Send + Sync + 'static> AdaptiveInstance for SharedVersionedChain<T>

Source§

fn header(&self) -> &HandshakeHeader

Source§

fn ring(&self) -> &ObservationRing

Source§

fn make_policy(&self) -> Box<dyn Policy>

Source§

fn apply_migration(&self, new_tag: u32)

Called by the sidecar when the policy returns a new strategy tag. Default implementation: just set the tag on the header. Primitives that need heavier migration (data-layout swap) override this to perform the swap before (or after) updating the tag.
Source§

impl<T: Copy + Send + 'static> Send for SharedVersionedChain<T>

Source§

impl<T: Copy + Sync + 'static> Sync for SharedVersionedChain<T>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.