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

Read an LZ4-compressed frame.

This reader reads the blocks inside a frame one by one.

Implementations§

source§

impl<R: Read> LZ4FrameReader<R>

source

pub fn new(reader: R) -> Result<Self, DecompressionError>

Create a new LZ4FrameReader over an underlying reader and parse the header.

A typical LZ4 file consists of exactly one frame. This reader will stop reading at the end of the frame. If you want to read any data following this frame, you should probably pass in your reader by reference, rather than by value.

source

pub fn block_size(&self) -> usize

Returns the maximum number of bytes a block can decompress to (as specified by the file header).

In general, all blocks in a frame except for the final one will have exactly this size. (Although this is not strictly enforced and may be violated by hand-crafted inputs)

source

pub fn frame_size(&self) -> Option<u64>

Returns the number of bytes that this entire frame is supposed to decompress to. This value is read directly from the file header and may be incorrect for malicious inputs.

source

pub fn dictionary_id(&self) -> Option<u32>

Return an identifier for the dictionary that was used to compress this frame.

Dictionary identifiers are always application-specific. Note that the lz4 command line utility never specifies a dictionary id, even if a dictionary was used.

source

pub fn into_read_with_dictionary( self, dictionary: &[u8] ) -> LZ4FrameIoReader<'_, R>

Convert this LZ4FrameReader into something that implements std::io::BufRead.

Note that io::copy has a small performance issue: https://github.com/rust-lang/rust/issues/49921

source

pub fn into_read(self) -> LZ4FrameIoReader<'static, R>

Convenience wrapper in case you don’t want to specify a dictionary.

source

pub fn decode_block( &mut self, output: &mut Vec<u8>, dictionary: &[u8] ) -> Result<(), DecompressionError>

Decode a single block.

The output buffer must be empty upon calling this method.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<R> UnwindSafe for LZ4FrameReader<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>,

§

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

§

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.