Skip to main content

LzfReader

Struct LzfReader 

Source
pub struct LzfReader<R: Read> { /* private fields */ }
Expand description

Framed LZF stream reader. Reader that decodes framed LZF (ZV block stream).

The reader consumes blocks lazily and yields decompressed bytes through the crate’s Read trait.

§Example

use lzf_rust::{LzfRead, LzfReader, encode_blocks};

let input = b"stream reader example";
let framed = encode_blocks(input, 4096).unwrap();
let mut src: &[u8] = &framed;
let mut reader = LzfReader::new(&mut src);

let mut out = vec![0u8; input.len()];
reader.read_exact(&mut out).unwrap();
assert_eq!(out, input);

Implementations§

Source§

impl<R: Read> LzfReader<R>

Source

pub fn new(inner: R) -> Self

Creates a new framed LZF reader.

Source

pub fn into_inner(self) -> R

Unwraps the reader and returns the underlying reader.

Source

pub fn inner(&self) -> &R

Returns a shared reference to the underlying reader.

Source

pub fn inner_mut(&mut self) -> &mut R

Returns a mutable reference to the underlying reader.

Trait Implementations§

Source§

impl<R: Read> Read for LzfReader<R>

Source§

fn read(&mut self, buf: &mut [u8]) -> DecodeResult<usize>

Reads bytes into buf, returning the number of bytes read.
Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>

Reads exactly buf.len() bytes into buf. Read more

Auto Trait Implementations§

§

impl<R> Freeze for LzfReader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for LzfReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for LzfReader<R>
where R: Send,

§

impl<R> Sync for LzfReader<R>
where R: Sync,

§

impl<R> Unpin for LzfReader<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for LzfReader<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for LzfReader<R>
where R: 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.