Struct lzss::LzssDyn

source ·
pub struct LzssDyn { /* private fields */ }
Expand description

Dynamic parameters for de-/compression (see Lzss for compile-time parameters).

Parameters

  • ei - The number of bits in the offset, usually 10..13
  • ej - The number of bits in the length, usually 4..5
  • c - The initial fill byte of the buffer, usually 0x20 (space)

Restrictions

  • ej must be larger than 0
  • ei must be larger than ej
  • ei + ej must be at least 8
  • ei + ej must be 24 or less

Example

let my_lzss = LzssDyn::new(10, 4, 0x20)?;
let input = b"Example Data";
let result = my_lzss.compress(
  SliceReader::new(input),
  VecWriter::with_capacity(30),
);
assert_eq!(result.void_unwrap().len(), 14); // the output is 14 bytes long

Implementations§

source§

impl LzssDyn

source

pub fn new(ei: usize, ej: usize, c: u8) -> Result<Self, LzssDynError>

Create new Lzss parameters.

If the parameter are not valid (see above) an error is returned.

For creating a const see Lzss::as_dyn.

source

pub const fn ei(&self) -> usize

Get the ei parameter.

source

pub const fn ej(&self) -> usize

Get the ej parameter.

source

pub const fn c(&self) -> u8

Get the c parameter.

source

pub fn compress<R: Read, W: Write>( &self, reader: R, writer: W ) -> Result<W::Output, LzssError<R::Error, W::Error>>

Available on crate features alloc or std only.

Compress the input data into the output.

The buffer, with 2 * (1 << EI) bytes, is allocated on the heap.

source

pub fn compress_with_buffer<R: Read, W: Write>( &self, reader: R, writer: W, buffer: &mut [u8] ) -> Result<W::Output, LzssError<R::Error, W::Error>>

Compress the input data into the output.

It will be asserted at runtime that the buffer is at least 2 * (1 << EI).

source

pub fn decompress<R: Read, W: Write>( &self, reader: R, writer: W ) -> Result<W::Output, LzssError<R::Error, W::Error>>

Available on crate features alloc or std only.

Decompress the input data into the output.

The buffer, with 1 << EI bytes, is allocated on the heap.

source

pub fn decompress_with_buffer<R: Read, W: Write>( &self, reader: R, writer: W, buffer: &mut [u8] ) -> Result<W::Output, LzssError<R::Error, W::Error>>

Decompress the input data into the output.

It will be asserted at runtime that the buffer is at least 1 << EI.

Trait Implementations§

source§

impl Clone for LzssDyn

source§

fn clone(&self) -> LzssDyn

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl PartialEq<LzssDyn> for LzssDyn

source§

fn eq(&self, other: &LzssDyn) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for LzssDyn

source§

impl Eq for LzssDyn

source§

impl StructuralEq for LzssDyn

source§

impl StructuralPartialEq for LzssDyn

Auto Trait Implementations§

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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.