Contiguous

Trait Contiguous 

Source
pub trait Contiguous {
    type Item;

    // Required methods
    fn size(&self) -> u64;
    fn oldest_retained_pos(&self) -> Option<u64>;
    fn pruning_boundary(&self) -> u64;
    fn replay(
        &self,
        start_pos: u64,
        buffer: NonZeroUsize,
    ) -> impl Future<Output = Result<impl Stream<Item = Result<(u64, Self::Item), Error>> + '_, Error>>;
    fn read(
        &self,
        position: u64,
    ) -> impl Future<Output = Result<Self::Item, Error>>;
}
Expand description

Core trait for contiguous journals supporting sequential append operations.

A contiguous journal maintains a consecutively increasing position counter where each appended item receives a unique position starting from 0.

Required Associated Types§

Source

type Item

The type of items stored in the journal.

Required Methods§

Source

fn size(&self) -> u64

Return the total number of items that have been appended to the journal.

This count is NOT affected by pruning. The next appended item will receive this position as its value.

Source

fn oldest_retained_pos(&self) -> Option<u64>

Return the position of the oldest item still retained in the journal.

Returns None if the journal is empty or if all items have been pruned.

After pruning, this returns the position of the first item that remains. Note that due to section/blob alignment, this may be less than the min_position passed to prune().

Source

fn pruning_boundary(&self) -> u64

Return the location before which all items have been pruned.

If this is the same as size(), then all items have been pruned.

Source

fn replay( &self, start_pos: u64, buffer: NonZeroUsize, ) -> impl Future<Output = Result<impl Stream<Item = Result<(u64, Self::Item), Error>> + '_, Error>>

Return a stream of all items in the journal starting from start_pos.

Each item is yielded as a tuple (position, item) where position is the item’s stable position in the journal.

§Errors

Returns an error if start_pos exceeds the journal size or if any storage/decoding errors occur during replay.

Source

fn read(&self, position: u64) -> impl Future<Output = Result<Self::Item, Error>>

Read the item at the given position.

§Errors

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<E, C, H, S> Contiguous for commonware_storage::journal::authenticated::Journal<E, C, H, S>
where E: Storage + Clock + Metrics, C: MutableContiguous<Item: Encode>, H: Hasher, S: State<DigestOf<H>>,

Source§

impl<E: Storage + Metrics, A: CodecFixed<Cfg = ()>> Contiguous for commonware_storage::journal::contiguous::fixed::Journal<E, A>

Source§

type Item = A

Source§

impl<E: Storage + Metrics, V: Codec> Contiguous for commonware_storage::journal::contiguous::variable::Journal<E, V>

Source§

type Item = V