pub struct StreamingWalReader<R: Read> { /* private fields */ }Expand description
Concrete WalStreamReader impl over an arbitrary std::io::Read.
Typical instantiations:
StreamingWalReader<std::fs::File>— on-disk archive readerStreamingWalReader<&[u8]>— in-memory test fixture (the common case in this module’s own test suite)
The underlying reader is wrapped in a BufReader, so the
per-record framing reads (1-byte EOF probe + 7-byte length-prefix
remainder) hit an in-memory buffer rather than issuing three raw
read calls per record against the source — file-backed streams
are efficient by construction, no caller-side wrapping needed.
Implementations§
Source§impl<R: Read> StreamingWalReader<R>
impl<R: Read> StreamingWalReader<R>
Sourcepub fn open_v1(reader: R) -> Result<Self, WalExportError>
pub fn open_v1(reader: R) -> Result<Self, WalExportError>
Open a reader by consuming + dispatching the 8-byte stream header magic.
Fail-fast posture: the 8-byte header is read into a stack
array; an unrecognised magic yields
WalExportError::UnsupportedStreamVersion with no
payload-sized allocation pre-rejection (the only allocation
before validation is the fixed-size BufReader working buffer,
independent of stream contents). A truncated header (fewer than
8 bytes) yields InvalidFramingReason::HeaderMissing.
Sourcepub fn magic(&self) -> StreamMagic
pub fn magic(&self) -> StreamMagic
Recognised stream magic version. Currently always
StreamMagic::V1.
Trait Implementations§
Source§impl<R: Read> WalStreamReader for StreamingWalReader<R>
impl<R: Read> WalStreamReader for StreamingWalReader<R>
Source§fn next_record(&mut self) -> Result<Option<&[u8]>, WalExportError>
fn next_record(&mut self) -> Result<Option<&[u8]>, WalExportError>
Source§fn cumulative_position(&self) -> u64
fn cumulative_position(&self) -> u64
[8 byte length prefix][payload] frame. Useful for forensic
“where did the parse fail” reporting and for operator metrics
(bytes-processed throughput).