deflate

Struct CompressionOptions

Source
pub struct CompressionOptions {
    pub max_hash_checks: u16,
    pub lazy_if_less_than: u16,
    pub matching_type: MatchingType,
    pub special: SpecialOptions,
}
Expand description

A struct describing the options for a compressor or compression function.

These values are not stable and still subject to change!

Fields§

§max_hash_checks: u16

The maximum number of checks to make in the hash table for matches.

Higher numbers mean slower, but better compression. Very high (say >1024) values will impact compression speed a lot. The maximum match length is 2^15, so values higher than this won’t make any difference, and will be truncated to 2^15 by the compression function/writer.

Default value: 128

§lazy_if_less_than: u16

Only lazy match if we have a length less than this value.

Higher values degrade compression slightly, but improve compression speed.

  • 0: Never lazy match. (Same effect as setting MatchingType to greedy, but may be slower).
  • 1...257: Only check for a better match if the first match was shorter than this value.
  • 258: Always lazy match.

As the maximum length of a match is 258, values higher than this will have no further effect.

  • Default value: 32
§matching_type: MatchingType

Whether to use lazy or greedy matching.

Lazy matching will provide better compression, at the expense of compression speed.

As a special case, if max_hash_checks is set to 0, and matching_type is set to lazy, compression using only run-length encoding (i.e maximum match distance of 1) is performed. (This may be changed in the future but is defined like this at the moment to avoid API breakage.

See MatchingType

  • Default value: MatchingType::Lazy
§special: SpecialOptions

Force fixed/stored blocks (Not implemented yet).

  • Default value: SpecialOptions::Normal

Implementations§

Source§

impl CompressionOptions

Source

pub const fn high() -> CompressionOptions

Returns compression settings roughly corresponding to the HIGH(9) setting in miniz.

Source

pub const fn fast() -> CompressionOptions

Returns a fast set of compression settings

Ideally this should roughly correspond to the FAST(1) setting in miniz. However, that setting makes miniz use a somewhat different algorithm, so currently hte fast level in this library is slower and better compressing than the corresponding level in miniz.

Source

pub const fn huffman_only() -> CompressionOptions

Returns a set of compression settings that makes the compressor only compress using Huffman coding. (Ignoring any length/distance matching)

This will normally have the worst compression ratio (besides only using uncompressed data), but may be the fastest method in some cases.

Source

pub const fn rle() -> CompressionOptions

Returns a set of compression settings that makes the compressor compress only using run-length encoding (i.e only looking for matches one byte back).

This is very fast, but tends to compress worse than looking for more matches using hash chains that the slower settings do. Works best on data that has runs of equivalent bytes, like binary or simple images, less good for text.

Trait Implementations§

Source§

impl Clone for CompressionOptions

Source§

fn clone(&self) -> CompressionOptions

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 Debug for CompressionOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CompressionOptions

Source§

fn default() -> CompressionOptions

Returns the options describing the default compression level.

Source§

impl From<Compression> for CompressionOptions

Source§

fn from(compression: Compression) -> CompressionOptions

Converts to this type from the input type.
Source§

impl Hash for CompressionOptions

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CompressionOptions

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for CompressionOptions

Source§

impl Eq for CompressionOptions

Source§

impl StructuralPartialEq for CompressionOptions

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

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