pub struct EventStoreReader<B> { /* private fields */ }Expand description
Read-only handle over an EventStore backend.
The reader is the canonical entry point for read-only replay, audit, and verifier
scans: it never mutates the backend (no append_batch surface) and it tolerates
running and sealed backends uniformly.
Implementations§
Source§impl<B: EventStore> EventStoreReader<B>
impl<B: EventStore> EventStoreReader<B>
Sourcepub fn manifest(&self) -> Result<RunManifest, EventStoreError>
pub fn manifest(&self) -> Result<RunManifest, EventStoreError>
Sourcepub fn high_watermark(&self) -> Result<u64, EventStoreError>
pub fn high_watermark(&self) -> Result<u64, EventStoreError>
Returns the largest seq durably acknowledged for the open run.
§Errors
Returns an error if no run is open.
Sourcepub fn scan_seq(
&self,
seq: u64,
) -> Result<Option<EventStoreEntry>, EventStoreError>
pub fn scan_seq( &self, seq: u64, ) -> Result<Option<EventStoreEntry>, EventStoreError>
Reads a single entry by seq.
Returns None when seq == 0 or seq exceeds the current high-watermark.
§Errors
Returns an error if the recomputed entry hash diverges from the stored value, if the row is missing inside the high-watermark, or if the backend fails.
Sourcepub fn lookup(
&self,
kind: IndexKind,
key: &str,
) -> Result<Option<u64>, EventStoreError>
pub fn lookup( &self, kind: IndexKind, key: &str, ) -> Result<Option<u64>, EventStoreError>
Looks up the first seq recorded under the given index key.
§Errors
Returns an error if the backend fails.
Sourcepub fn latest_snapshot_anchor(
&self,
) -> Result<Option<SnapshotAnchor>, EventStoreError>
pub fn latest_snapshot_anchor( &self, ) -> Result<Option<SnapshotAnchor>, EventStoreError>
Returns the latest snapshot anchor for the run.
Returns Ok(None) when no snapshot anchor has been recorded yet.
§Errors
Returns an error if no run is open or the backend does not support snapshot anchors, or if a stored anchor cannot decode.
Sourcepub fn snapshot_replay_plan(
&self,
) -> Result<SnapshotReplayPlan, EventStoreError>
pub fn snapshot_replay_plan( &self, ) -> Result<SnapshotReplayPlan, EventStoreError>
Builds the restore replay bounds from the latest snapshot anchor.
Restore callers fetch and validate the cache-owned snapshot blob first, then
replay entries in [from_seq, to_seq]. When an anchor exists, from_seq is
anchor.high_watermark + 1; without an anchor, restore replays from seq 1.
§Errors
Returns an error if no run is open or the backend does not support snapshot anchors, or if the stored anchor points past the durable high-watermark.
Sourcepub fn scan_snapshot_replay_tail(
&self,
) -> Result<(SnapshotReplayPlan, RangeScan<'_>), EventStoreError>
pub fn scan_snapshot_replay_tail( &self, ) -> Result<(SnapshotReplayPlan, RangeScan<'_>), EventStoreError>
Scans the forward replay tail after the latest snapshot anchor.
This pairs Self::snapshot_replay_plan with the actual event iterator used by
restore: entries start at anchor.high_watermark + 1 when an anchor exists, or
at seq 1 when no cache snapshot has been anchored.
§Errors
Returns an error if Self::snapshot_replay_plan fails.
Sourcepub fn scan_range(
&self,
from: u64,
to: u64,
direction: ScanDirection,
) -> RangeScan<'_> ⓘ
pub fn scan_range( &self, from: u64, to: u64, direction: ScanDirection, ) -> RangeScan<'_> ⓘ
Scans entries by seq over the inclusive range [from, to].
The returned iterator pulls DEFAULT_SCAN_CHUNK_SIZE entries at a time from the
backend so a multi-million-entry forensics scan keeps the working set bounded
while still amortizing per-transaction overhead. The iterator yields one entry
per call; backend errors surface as Some(Err(...)) and terminate the scan.
Sourcepub fn scan_range_chunked(
&self,
from: u64,
to: u64,
direction: ScanDirection,
chunk_size: u64,
) -> RangeScan<'_> ⓘ
pub fn scan_range_chunked( &self, from: u64, to: u64, direction: ScanDirection, chunk_size: u64, ) -> RangeScan<'_> ⓘ
Variant of Self::scan_range with a caller-chosen chunk size.
chunk_size == 0 is normalized to 1; the reader never asks the backend for a
degenerate empty window because the chunk window is the only progress signal the
iterator advances on.
Sourcepub fn into_inner(self) -> B
pub fn into_inner(self) -> B
Returns the underlying backend, consuming the reader.
Trait Implementations§
Auto Trait Implementations§
impl<B> Freeze for EventStoreReader<B>where
B: Freeze,
impl<B> RefUnwindSafe for EventStoreReader<B>where
B: RefUnwindSafe,
impl<B> Send for EventStoreReader<B>where
B: Send,
impl<B> Sync for EventStoreReader<B>where
B: Sync,
impl<B> Unpin for EventStoreReader<B>where
B: Unpin,
impl<B> UnsafeUnpin for EventStoreReader<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for EventStoreReader<B>where
B: UnwindSafe,
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more