Skip to main content

WalStreamReader

Trait WalStreamReader 

Source
pub trait WalStreamReader {
    // Required methods
    fn next_record(&mut self) -> Result<Option<&[u8]>, WalExportError>;
    fn cumulative_position(&self) -> u64;
}
Expand description

Reader-side trait — next_record plus cumulative_position.

The next_record lifetime tie (&mut self borrow → &[u8] borrow on the return) makes this trait a streaming iterator rather than a std::iter::Iterator. Callers iterate via:

while let Some(payload) = reader.next_record()? {
    // decode `payload` here; the slice expires next iteration
}

Required Methods§

Source

fn next_record(&mut self) -> Result<Option<&[u8]>, WalExportError>

Read the next record’s payload bytes.

Returns:

  • Ok(Some(payload)) — a borrow into the reader’s internal buffer, valid until the next call.
  • Ok(None) — clean EOF, no more records.
  • Err(WalExportError::InvalidFraming(...)) — framing reject per the five fail-secure paths documented above.
  • Err(WalExportError::Io(...)) — underlying I/O failure.
Source

fn cumulative_position(&self) -> u64

Cumulative byte count consumed from the underlying reader, including the 8-byte stream header magic + each record’s [8 byte length prefix][payload] frame. Useful for forensic “where did the parse fail” reporting and for operator metrics (bytes-processed throughput).

Implementors§