pub struct Decoder<E, R> { /* private fields */ }Expand description
Streaming decoder for one segment: reads the header on construction, then yields entries one at a time, carrying the cross-entry state (timestamp base, UUID dictionary) that delta- and dictionary-decoding need.
Implementations§
Source§impl<E: Op, R: BufRead> Decoder<E, R>
impl<E: Op, R: BufRead> Decoder<E, R>
Sourcepub fn new(read: R, magic: &[u8]) -> Result<Option<Self>, CodecError>
pub fn new(read: R, magic: &[u8]) -> Result<Option<Self>, CodecError>
magic is the app-supplied segment identity the encoder wrote (see
Encoder::new). A segment whose leading
bytes don’t match is rejected as foreign with CodecError::BadMagic.
Sourcepub fn decode_entry(&mut self) -> Result<Option<DecodedEntry<E>>, CodecError>
pub fn decode_entry(&mut self) -> Result<Option<DecodedEntry<E>>, CodecError>
Decode the next entry, or None at end of segment. On error, the
decoder’s cross-entry state is rolled back so a partial failure doesn’t
corrupt subsequent decoding.
Sourcepub fn decode_all(
buf: R,
magic: &[u8],
) -> (Option<DecodedLogs<E>>, Option<CodecError>)
pub fn decode_all( buf: R, magic: &[u8], ) -> (Option<DecodedLogs<E>>, Option<CodecError>)
Decode an entire segment in one call. Returns whatever entries decoded
successfully plus the first error, if any — entries before a failure
are still returned. None logs means the input held no segment (empty)
or the header itself was rejected (with the error).