Skip to main content

AutoTier

Enum AutoTier 

Source
pub enum AutoTier {
    Fast,
    Balanced,
    Small,
}
Available on crate feature enc only.
Expand description

Which codecs a selection pass is allowed to try.

Compression runs once, in the proc macro; decompression runs in every consumer’s shipped binary on every access. The two are not interchangeable costs, so the tiers cut the codec set by decode speed and each keeps the smallest output within its own candidates. Measured on a 125,976-byte executable, with the decoders this crate actually ships:

tierwins withpayloaddecode
FastLZ481,798 B2,775 MB/s
BalancedZstd56,140 B112 MB/s
SmallLZMA52,512 B41 MB/s

The tiers are nested, so a wider one never picks a larger payload than a narrower one. They are fixed membership rather than a cost function: which codec a build selects has to be predictable from the asset and the enabled features alone, never from how fast the build machine is.

The tier is a build-time policy. An entry header records the one CodecId that won, so nothing about it reaches the decode side.

Variants§

§

Fast

Store, Lz4, Snappy — the codecs that decode at GB/s.

Selected by codec = auto_fast. Also by far the cheapest to encode: it runs neither the LZMA nor the Zstd encoder, both of which search hard enough to cost minutes on a large, poorly compressible asset. Measured on 32 MiB of such data: this tier took 0.2 s where Balanced took 180 s.

§

Balanced

Fast plus Deflate and Zstd.

Selected by codec = auto, and the balance point the auto family is named for: roughly a third off the payload Fast picks, and still read back around three times quicker than LZMA’s.

The balance is in decode speed, which the consumer’s binary pays on every access. It is not cheap to encode: Zstd parses each block by price over several passes, so a large asset costs this tier minutes at build time. See the README’s note on build times.

§

Small

Balanced plus Lzma — every compressing codec there is.

Selected by codec = auto_small. The smallest binary available, at the slowest decode. Its build cost is close to Balanced’s rather than far above it, since both tiers run a codec that searches hard: 226 s against 180 s on the same 32 MiB asset.

Trait Implementations§

Source§

impl Clone for AutoTier

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for AutoTier

Source§

impl Debug for AutoTier

Source§

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

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

impl Eq for AutoTier

Source§

impl PartialEq for AutoTier

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AutoTier

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.