Skip to main content

WalFsReader

Struct WalFsReader 

Source
pub struct WalFsReader { /* private fields */ }
Expand description

A file system backed WAL reader.

The reader opens a file and sequentially reads encoded WAL events. Each event is expected to follow the framed binary format from the codec:

  • 4 bytes version (currently 2)
  • 4 bytes length of payload
  • 4 bytes CRC-32 checksum
  • payload bytes

If strict framed validation finds corruption, the reader returns WalReaderError::Corruption with typed offset+reason diagnostics.

Implementations§

Source§

impl WalFsReader

Source

pub fn new(path: PathBuf) -> Result<Self, WalFsReaderError>

Creates a new WAL reader from the given path.

Opens the file in read-only mode and positions the reader at the beginning of the file. The reader will start reading from sequence 0 (or the first event in the file).

§Arguments
  • path - The filesystem path to the WAL file
§Errors

Returns WalFsReaderError::IoError if the file cannot be opened.

Source

pub fn current_sequence(&self) -> u64

Returns the current sequence number being read.

Source

pub fn reset_eof(&mut self)

Resets the end-of-file flag, allowing the reader to attempt reading new events that may have been appended after the previous EOF.

Trait Implementations§

Source§

impl WalReader for WalFsReader

Source§

fn read_next(&mut self) -> Result<Option<WalEvent>, WalReaderError>

Read the next event from the WAL.

Attempts to read the next complete event from the file. If strict tail validation detects corruption at or after the current cursor, returns WalReaderError::Corruption.

If the end of the file is reached with no corruption (all events read), returns Ok(None).

§Errors

Returns WalReaderError::Corruption if strict corruption is encountered.

Returns WalReaderError::IoError if an I/O error occurs.

Source§

fn seek_to_sequence(&mut self, sequence: u64) -> Result<(), WalReaderError>

Seek to a specific sequence number.

This implementation performs a linear scan from the beginning of the file to find the event with the specified sequence number. This is O(n) but guarantees correctness.

If the sequence number is not found in the file, returns WalReaderError::EndOfWal.

§Errors

Returns WalReaderError::Corruption if any corruption is detected while scanning. Per strict policy this fails even when target sequence appears before corruption.

Source§

fn is_end(&self) -> bool

Returns true if the reader is at the end of the WAL.

Returns true if all complete events have been read or if corruption was encountered.

Auto Trait Implementations§

Blanket Implementations§

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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, 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<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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