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, usually10..13
ej
- The number of bits in the length, usually4..5
c
- The initial fill byte of the buffer, usually0x20
(space)
Restrictions
ej
must be larger than0
ei
must be larger thanej
ei + ej
must be at least 8ei + 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
impl LzssDyn
sourcepub fn new(ei: usize, ej: usize, c: u8) -> Result<Self, LzssDynError>
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
.
sourcepub 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.
pub fn compress<R: Read, W: Write>( &self, reader: R, writer: W ) -> Result<W::Output, LzssError<R::Error, W::Error>>
alloc
or std
only.Compress the input data into the output.
The buffer, with 2 * (1 << EI)
bytes, is allocated on the heap.
sourcepub fn compress_with_buffer<R: Read, W: Write>(
&self,
reader: R,
writer: W,
buffer: &mut [u8]
) -> Result<W::Output, LzssError<R::Error, W::Error>>
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)
.
Trait Implementations§
source§impl PartialEq<LzssDyn> for LzssDyn
impl PartialEq<LzssDyn> for LzssDyn
impl Copy for LzssDyn
impl Eq for LzssDyn
impl StructuralEq for LzssDyn
impl StructuralPartialEq for LzssDyn
Auto Trait Implementations§
impl RefUnwindSafe for LzssDyn
impl Send for LzssDyn
impl Sync for LzssDyn
impl Unpin for LzssDyn
impl UnwindSafe for LzssDyn
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more