Skip to main content

Decoder

Struct Decoder 

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

Source

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.

Source

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.

Source

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).

Auto Trait Implementations§

§

impl<E, R> Freeze for Decoder<E, R>
where R: Freeze,

§

impl<E, R> RefUnwindSafe for Decoder<E, R>

§

impl<E, R> Send for Decoder<E, R>
where R: Send, E: Send,

§

impl<E, R> Sync for Decoder<E, R>
where R: Sync, E: Sync,

§

impl<E, R> Unpin for Decoder<E, R>
where R: Unpin, E: Unpin,

§

impl<E, R> UnsafeUnpin for Decoder<E, R>
where R: UnsafeUnpin,

§

impl<E, R> UnwindSafe for Decoder<E, R>
where R: UnwindSafe, E: UnwindSafe,

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, 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.