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;
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,
read_options: ReadOptions,
) -> 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§
Required Methods§
Sourcefn bounds(&self) -> Range<u64> ⓘ
fn bounds(&self) -> Range<u64> ⓘ
Returns [start, end) with a guaranteed stable pruning boundary.
Sourcefn read(
&self,
position: u64,
) -> impl Future<Output = Result<Self::Item, Error>> + Send + Sync
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().
Sourcefn read_many(
&self,
positions: &[u64],
) -> impl Future<Output = Result<Vec<Self::Item>, Error>> + Send
fn read_many( &self, positions: &[u64], ) -> impl Future<Output = Result<Vec<Self::Item>, Error>> + 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.
Sourcefn try_read_sync(&self, position: u64) -> Option<Self::Item>
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.
Sourcefn try_read_many_sync(&self, positions: &[u64]) -> Vec<Option<Self::Item>>
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.
Sourcefn replay(
&self,
start_pos: u64,
buffer: NonZeroUsize,
read_options: ReadOptions,
) -> impl Future<Output = Result<impl Stream<Item = Result<(u64, Self::Item), Error>> + Send, Error>> + Send
fn replay( &self, start_pos: u64, buffer: NonZeroUsize, read_options: ReadOptions, ) -> 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. Every backing blob read from
sealed history uses read_options. Backing reads from the live writable tip instead use
ReadOptions::DONT_CACHE on page-cache misses because the cache retains the fetched pages.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".