Skip to main content

Contiguous

Trait Contiguous 

Source
pub trait Contiguous: Send + Sync {
    type Item: Send;

    // Required methods
    fn bounds(&self) -> Range<u64>;
    fn read(
        &self,
        position: u64,
    ) -> impl Future<Output = Result<Self::Item, Error>> + Send + Sync;
    fn read_many(
        &self,
        positions: &[u64],
    ) -> impl Future<Output = Result<Vec<Self::Item>, Error>> + Send
       where Self::Item: Send;
    fn try_read_sync(&self, position: u64) -> Option<Self::Item>;
    fn try_read_many_sync(&self, positions: &[u64]) -> Vec<Option<Self::Item>>;
    fn replay(
        &self,
        start_pos: u64,
        buffer: NonZeroUsize,
    ) -> impl Future<Output = Result<impl Stream<Item = Result<(u64, Self::Item), Error>> + Send, Error>> + Send;
}
Expand description

A read-only, position-based view of a contiguous journal.

Maintains a monotonically increasing position counter where each appended item receives a unique position starting from 0.

Required Associated Types§

Source

type Item: Send

The type of items stored in the journal.

Required Methods§

Source

fn bounds(&self) -> Range<u64>

Returns [start, end) with a guaranteed stable pruning boundary.

Source

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

Read the item at the given position.

Guaranteed not to return Error::ItemPruned for positions within bounds().

Source

fn read_many( &self, positions: &[u64], ) -> impl Future<Output = Result<Vec<Self::Item>, Error>> + Send
where Self::Item: Send,

Read multiple items at the given positions, which must be strictly increasing.

Equivalent to serving every position try_read_many_sync declines with one batched read. Implementations may fuse the two passes.

Source

fn try_read_sync(&self, position: u64) -> Option<Self::Item>

Read an item if it can be done synchronously (e.g. without I/O), returning None otherwise. Decode failures surface as None and the async read path reports the error.

Source

fn try_read_many_sync(&self, positions: &[u64]) -> Vec<Option<Self::Item>>

Probe multiple strictly increasing positions, serving those that can be read synchronously (e.g. from a page cache) and returning one slot per position. Positions that require I/O, fail to decode, or fall outside bounds() decline to None. The async read paths are the sole error authority for declined positions.

Source

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

Return a stream of all items starting from start_pos, bounded by bounds().

buffer controls the replay byte budget for each chunk.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<E: Context, A: CodecFixedShared> Contiguous for commonware_storage::journal::contiguous::fixed::Journal<E, A>

Source§

type Item = A

Source§

impl<E: Context, A: CodecFixedShared> Contiguous for commonware_storage::journal::contiguous::fixed::Reader<'_, E, A>

Source§

type Item = A

Source§

impl<E: Context, V: CodecShared> Contiguous for commonware_storage::journal::contiguous::variable::Journal<E, V>

Source§

type Item = V

Source§

impl<E: Context, V: CodecShared> Contiguous for commonware_storage::journal::contiguous::variable::Reader<'_, E, V>

Source§

type Item = V

Source§

impl<F, E, C, H, S> Contiguous for commonware_storage::journal::authenticated::Journal<F, E, C, H, S>
where F: Family, E: Context, C: Contiguous<Item: EncodeShared>, H: Hasher, S: Strategy,