Skip to main content

ErrorKind

Enum ErrorKind 

Source
#[non_exhaustive]
pub enum ErrorKind {
Show 20 variants InvalidBlockType, InvalidStoredLength, InvalidCodeLengths, InvalidSymbol, DistanceTooFar, UnexpectedEnd, OutputLimit, RatioLimit, TrailingData, InvalidWindowBits, InvalidLevel, InvalidHeader, ChecksumMismatch, LengthMismatch, HeaderTooLarge, TooManyMembers, DictionaryRequired, WrongDictionary, InvalidState, AllocationFailed,
}
Expand description

What went wrong, as a stable, matchable value.

Every kind says what to do in its message and has a stable code for logs and metrics. New kinds may be added in minor releases, so match with a wildcard arm.

§Examples

use compress_lib::ErrorKind;

assert_eq!(ErrorKind::OutputLimit.code(), "compress.output_limit");

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

InvalidBlockType

A DEFLATE block header names block type 3, which does not exist.

§

InvalidStoredLength

A stored block’s length and its one’s complement disagree.

§

InvalidCodeLengths

A Huffman code description is invalid: over-subscribed, incomplete where the format forbids it, a repeat with no previous length, or a repeat that runs past the end of the table.

§

InvalidSymbol

A code decodes to a symbol the format reserves (length symbols 286 and 287, distance symbols 30 and 31) or to no symbol at all.

§

DistanceTooFar

A back-reference points before the start of the data (and any preset dictionary) or further back than the window allows.

§

UnexpectedEnd

The input ended inside the stream: the data is truncated.

§

OutputLimit

The output reached the configured max_output before the stream ended.

§

RatioLimit

The output grew past the configured ratio to the input consumed.

§

TrailingData

Bytes follow the end of the stream where none are allowed.

§

InvalidWindowBits

A window size outside 8 to 15 bits was asked for, or a zlib header names a window larger than the decoder allows.

§

InvalidLevel

A compression level outside 0 to 9 was asked for.

§

InvalidHeader

A zlib or gzip header is malformed.

§

ChecksumMismatch

A checksum (Adler-32, CRC-32, or the gzip header CRC) does not match the data.

§

LengthMismatch

The gzip trailer’s length does not match the data.

§

HeaderTooLarge

The gzip header’s optional fields are larger than the configured cap.

§

TooManyMembers

A gzip stream has more members than the configured cap.

§

DictionaryRequired

A zlib stream needs a preset dictionary that was not given.

§

WrongDictionary

The preset dictionary given is not the one the zlib stream names.

§

InvalidState

The call is not valid in the engine’s current state.

§

AllocationFailed

The allocator refused memory for output.

Implementations§

Source§

impl ErrorKind

Source

pub const fn code(self) -> &'static str

A stable identifier for logs and metrics, never changed once released.

§Examples
use compress_lib::ErrorKind;

assert_eq!(ErrorKind::DistanceTooFar.code(), "compress.distance_too_far");
Source

pub const fn message(self) -> &'static str

What happened and what to do, in one sentence.

§Examples
use compress_lib::ErrorKind;

assert!(ErrorKind::OutputLimit.message().contains("max_output"));

Trait Implementations§

Source§

impl Clone for ErrorKind

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 ErrorKind

Source§

impl Debug for ErrorKind

Source§

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

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

impl Display for ErrorKind

Source§

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

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

impl Eq for ErrorKind

Source§

impl From<Error> for ErrorKind

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl Hash for ErrorKind

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 ErrorKind

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 ErrorKind

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.