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 an error if 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 an error if 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 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.

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 an error if the backend fails.

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 an error if no run is open or the backend does not support snapshot anchors, or if 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 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.

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

Returns an error if Self::snapshot_replay_plan fails.

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§

§

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
§

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

§

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<T> Ungil for T
where T: Send,

§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more