Skip to main content

EventStoreReader

Struct EventStoreReader 

Source
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>

Source

pub const fn new(backend: B) -> Self

Wraps backend for read-only access.

Source

pub fn manifest(&self) -> Result<RunManifest, EventStoreError>

Returns the manifest of the open run.

§Errors

Returns EventStoreError::Backend when no run is open.

Source

pub fn high_watermark(&self) -> Result<u64, EventStoreError>

Returns the largest seq durably acknowledged for the open run.

§Errors

Returns EventStoreError::Backend when no run is open.

Source

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 EventStoreError::HashMismatch when the recomputed entry hash diverges from the stored value, EventStoreError::Gap when the row is missing inside the high-watermark, and EventStoreError::Backend for unclassified backend failures.

Source

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 EventStoreError::Backend for unclassified backend failures.

Source

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 EventStoreError::Backend when no run is open or the backend does not support snapshot anchors, and EventStoreError::Corrupted when a stored anchor cannot decode.

Source

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 EventStoreError::Backend when no run is open or the backend does not support snapshot anchors, and EventStoreError::Corrupted when the stored anchor points past the durable high-watermark.

Source

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

See Self::snapshot_replay_plan.

Source

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.

Source

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.

Source

pub fn into_inner(self) -> B

Returns the underlying backend, consuming the reader.

Source

pub const fn backend(&self) -> &B

Returns a reference to the underlying backend.

Trait Implementations§

Source§

impl<B: Debug> Debug for EventStoreReader<B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V