Enum DeflateCompression

Source
#[non_exhaustive]
pub enum DeflateCompression { NoCompression, FdeflateUltraFast, Level(u8), }
Expand description

Advanced compression settings with more customization options than Compression.

Note that this setting only affects DEFLATE compression. Another setting that influences the compression ratio and lets you choose between encoding speed and compression ratio is the Filter.

§Stability guarantees

The implementation details of DEFLATE compression may evolve over time, even without a semver-breaking change to the version of png crate.

If a certain compression setting is superseded by other options, it may be marked deprecated and remapped to a different option. You will see a deprecation notice when compiling code relying on such options.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

NoCompression

Do not compress the data at all.

Useful for incompressible images, or when speed is paramount and you don’t care about size at all.

This mode also disables filters, forcing Filter::NoFilter.

§

FdeflateUltraFast

Excellent for creating lightly compressed PNG images very quickly.

Uses the fdeflate crate under the hood to achieve speeds far exceeding what libpng is capable of while still providing a decent compression ratio.

Note: When used in streaming mode, this compression level can actually result in files larger than would be produced by NoCompression because it doesn’t do any buffering of the output stream to detect whether the data is being compressed or not.

§

Level(u8)

Compression level between 1 and 9, where higher values mean better compression at the cost of speed.

This is currently implemented via flate2 crate by passing through the compression level.

The implementation details and the exact meaning of each level may change in the future, including in semver-compatible releases.

Trait Implementations§

Source§

impl Clone for DeflateCompression

Source§

fn clone(&self) -> DeflateCompression

Returns a duplicate 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 DeflateCompression

Source§

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

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

impl Default for DeflateCompression

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Copy for DeflateCompression

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.