Struct litetx::Decoder

source ·
pub struct Decoder<'a, R>where
    R: Read,{ /* private fields */ }
Expand description

An LTX file decoder.

Example

let (mut dec, header) = litetx::Decoder::new(r).expect("decoder");

let mut buf = vec![0; header.page_size.into_inner() as usize];
while let Some(page_num) = dec.decode_page(&mut buf).expect("decode_page") {
    // do something with the page
}

let trailer = dec.finish().expect("finish");

Implementations§

source§

impl<'a, R> Decoder<'a, R>where R: Read,

source

pub fn new(r: R) -> Result<(Decoder<'a, R>, Header), Error>

Construct a new Decoder that reads from r.

source

pub fn decode_page(&mut self, data: &mut [u8]) -> Result<Option<PageNum>, Error>

Decode the next page from the LTX file.

Returns Ok(Some(page_num)) if a page has been successfully decoded. Return Ok(None) if the LTX file doesn’t have any more pages.

source

pub fn finish(self) -> Result<Trailer, Error>

Consume the decoder and verify file checksum.

Auto Trait Implementations§

§

impl<'a, R> RefUnwindSafe for Decoder<'a, R>where R: RefUnwindSafe,

§

impl<'a, R> Send for Decoder<'a, R>where R: Send,

§

impl<'a, R> Sync for Decoder<'a, R>where R: Sync,

§

impl<'a, R> Unpin for Decoder<'a, R>where R: Unpin,

§

impl<'a, R> UnwindSafe for Decoder<'a, R>where R: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.