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
impl WalFsReader
Sourcepub fn new(path: PathBuf) -> Result<Self, WalFsReaderError>
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.
Sourcepub fn current_sequence(&self) -> u64
pub fn current_sequence(&self) -> u64
Returns the current sequence number being read.
Trait Implementations§
Source§impl WalReader for WalFsReader
impl WalReader for WalFsReader
Source§fn read_next(&mut self) -> Result<Option<WalEvent>, WalReaderError>
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>
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.