[−][src]Struct compression::prelude::LzssEncoder
Examples
use compression::prelude::*; use std::cmp::Ordering; fn main() { pub fn comparison(lhs: LzssCode, rhs: LzssCode) -> Ordering { match (lhs, rhs) { ( LzssCode::Reference { len: llen, pos: lpos, }, LzssCode::Reference { len: rlen, pos: rpos, }, ) => ((llen << 3) + rpos).cmp(&((rlen << 3) + lpos)).reverse(), (LzssCode::Symbol(_), LzssCode::Symbol(_)) => Ordering::Equal, (_, LzssCode::Symbol(_)) => Ordering::Greater, (LzssCode::Symbol(_), _) => Ordering::Less, } } let compressed = b"aabbaabbaabbaabb\n" .into_iter() .cloned() .encode(&mut LzssEncoder::new(comparison, 0x1_0000, 256, 3, 3), Action::Finish) .collect::<Result<Vec<_>, _>>() .unwrap(); let decompressed = compressed .iter() .cloned() .decode(&mut LzssDecoder::new(0x1_0000)) .collect::<Result<Vec<_>, _>>() .unwrap(); }
Methods
impl<F> LzssEncoder<F> where
F: Fn(LzssCode, LzssCode) -> Ordering + Copy,
[src]
F: Fn(LzssCode, LzssCode) -> Ordering + Copy,
pub fn new(
comp: F,
size_of_window: usize,
max_match: usize,
min_match: usize,
lazy_level: usize
) -> Self
[src]
comp: F,
size_of_window: usize,
max_match: usize,
min_match: usize,
lazy_level: usize
) -> Self
pub fn with_dict(
comp: F,
size_of_window: usize,
max_match: usize,
min_match: usize,
lazy_level: usize,
dict: &[u8]
) -> Self
[src]
comp: F,
size_of_window: usize,
max_match: usize,
min_match: usize,
lazy_level: usize,
dict: &[u8]
) -> Self
Trait Implementations
impl<F> Encoder for LzssEncoder<F> where
F: Fn(LzssCode, LzssCode) -> Ordering + Copy,
[src]
F: Fn(LzssCode, LzssCode) -> Ordering + Copy,
type Error = CompressionError
type In = u8
type Out = LzssCode
fn next<I: Iterator<Item = u8>>(
&mut self,
iter: &mut I,
action: Action
) -> Option<Result<LzssCode, CompressionError>>
[src]
&mut self,
iter: &mut I,
action: Action
) -> Option<Result<LzssCode, CompressionError>>
impl<F: Debug> Debug for LzssEncoder<F> where
F: Fn(LzssCode, LzssCode) -> Ordering + Copy,
[src]
F: Fn(LzssCode, LzssCode) -> Ordering + Copy,
Auto Trait Implementations
impl<F> Send for LzssEncoder<F> where
F: Send,
F: Send,
impl<F> Sync for LzssEncoder<F> where
F: Sync,
F: Sync,
impl<F> Unpin for LzssEncoder<F> where
F: Unpin,
F: Unpin,
impl<F> UnwindSafe for LzssEncoder<F> where
F: UnwindSafe,
F: UnwindSafe,
impl<F> RefUnwindSafe for LzssEncoder<F> where
F: RefUnwindSafe,
F: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,