Enum DeflateCompression

#[non_exhaustive]
pub enum DeflateCompression

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

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

impl Clone for DeflateCompression

fn clone(&self) -> Self

impl Copy for DeflateCompression

impl Debug for DeflateCompression

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

impl Default for DeflateCompression

fn default() -> Self

Auto Trait Implementations

impl Freeze for DeflateCompression

impl RefUnwindSafe for DeflateCompression

impl Send for DeflateCompression

impl Sync for DeflateCompression

impl Unpin for DeflateCompression

impl UnsafeUnpin for DeflateCompression

impl UnwindSafe for DeflateCompression

Blanket Implementations

impl<T> Any for DeflateCompression where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for DeflateCompression where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for DeflateCompression where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for DeflateCompression where T: Clone,

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

impl<T> From<T> for DeflateCompression

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for DeflateCompression where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for DeflateCompression where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for DeflateCompression where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for DeflateCompression where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>