pub trait Contiguous: Send + Sync {
type Item: Send + Sync;
// Required methods
fn bounds(&self) -> Range<u64> ⓘ;
fn read(
&self,
position: u64,
) -> impl Future<Output = Result<Self::Item, Error>> + Send;
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,
range: Range<u64>,
buffer: NonZeroUsize,
read_options: ReadOptions,
) -> impl Future<Output = Result<impl Stream<Item = Result<Batch<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.
Returned items may retain shared backing allocations larger than their byte fields.
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
fn read( &self, position: u64, ) -> impl Future<Output = Result<Self::Item, Error>> + Send
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,
range: Range<u64>,
buffer: NonZeroUsize,
read_options: ReadOptions,
) -> impl Future<Output = Result<impl Stream<Item = Result<Batch<Self::Item>, Error>> + Send, Error>> + Send
fn replay( &self, range: Range<u64>, buffer: NonZeroUsize, read_options: ReadOptions, ) -> impl Future<Output = Result<impl Stream<Item = Result<Batch<Self::Item>, Error>> + Send, Error>> + Send
Return a stream of the items in range as Batches of consecutive items, in position
order. range must fall within bounds(). An empty range within bounds() yields an
empty stream.
Every batch holds at least one item, consecutive batches are contiguous, and no batch
crosses a backing blob boundary. A batch’s items exceed buffer bytes as stored, framing
and compression included, by less than one item.
Backing reads of item data carry read_options, except reads served through the page
cache, which applies its own policy.
§Errors
Returns Error::ItemPruned if range.start precedes bounds().start, or
Error::ItemOutOfRange if range.end exceeds bounds().end or the range is inverted
(start > end).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".