Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 20 variants Io { format: Format, path: PathBuf, source: Error, }, UnexpectedEof { format: Format, offset: usize, needed: usize, available: usize, }, InvalidMagic { format: Format, found: Vec<u8>, }, UnsupportedVariant { format: Format, found: Vec<u8>, }, UnsupportedVersion { format: Format, found: Vec<u8>, }, OddUtf16ByteLength { format: Format, field: &'static str, offset: usize, length: usize, }, InvalidUtf16 { format: Format, field: &'static str, offset: usize, source: DecodeUtf16Error, }, InvalidUtf8 { format: Format, field: &'static str, offset: usize, source: Utf8Error, }, InvalidAscii { format: Format, field: &'static str, offset: usize, byte: u8, }, InvalidCompression { format: Format, offset: usize, status: i32, }, InvalidOffset { format: Format, field: &'static str, offset: usize, minimum: usize, maximum: usize, }, SizeMismatch { format: Format, field: &'static str, expected: u64, actual: u64, }, AllocationFailed { format: Format, field: &'static str, requested: usize, source: TryReserveError, }, InvalidCount { format: Format, field: &'static str, count: u64, maximum: u64, }, DuplicateCodeIndex { format: Format, index: u64, }, InvalidCodeIndex { format: Format, index: u64, offset: usize, }, InvalidCodeComponent { format: Format, field: &'static str, index: u64, offset: usize, }, InvalidRecordHeader { format: Format, field: &'static str, offset: usize, found: Vec<u8>, }, InvalidExtensionLength { format: Format, field: &'static str, offset: usize, length: usize, minimum: usize, }, CountMismatch { format: Format, field: &'static str, expected: u64, actual: u64, },
}
Expand description

Errors returned while reading or parsing a dictionary.

Every variant retains the source format and structured diagnostic data so callers can distinguish malformed input, unsupported data, and I/O errors without inspecting the displayed error message.

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

Io

A dictionary file could not be read.

Fields

§format: Format

Dictionary format requested by the caller.

§path: PathBuf

Path that could not be read.

§source: Error

Underlying filesystem error.

§

UnexpectedEof

A read extended past the available input.

Fields

§format: Format

Dictionary format being parsed.

§offset: usize

Byte offset at which the read was attempted.

§needed: usize

Number of bytes required by the read.

§available: usize

Number of bytes available from offset.

§

InvalidMagic

The dictionary magic bytes were invalid.

Fields

§format: Format

Dictionary format being parsed.

§found: Vec<u8>

Magic bytes found in the input.

§

UnsupportedVariant

The container variant was not supported.

Fields

§format: Format

Dictionary format being parsed.

§found: Vec<u8>

Variant bytes found in the input.

§

UnsupportedVersion

The format version was not supported.

Fields

§format: Format

Dictionary format being parsed.

§found: Vec<u8>

Version bytes found in the input.

§

OddUtf16ByteLength

A UTF-16LE field declared an odd number of bytes.

Fields

§format: Format

Dictionary format being parsed.

§field: &'static str

Name of the field being parsed.

§offset: usize

Offset of the field contents.

§length: usize

Declared byte length.

§

InvalidUtf16

A field contained invalid UTF-16.

Fields

§format: Format

Dictionary format being parsed.

§field: &'static str

Name of the field being parsed.

§offset: usize

Offset of the field contents.

§source: DecodeUtf16Error

Underlying UTF-16 decoder error.

§

InvalidUtf8

A field contained invalid UTF-8.

Fields

§format: Format

Dictionary format being parsed.

§field: &'static str

Name of the field being parsed.

§offset: usize

Offset of the field contents.

§source: Utf8Error

Underlying UTF-8 decoder error.

§

InvalidAscii

A field declared as ASCII contained a non-ASCII byte.

Fields

§format: Format

Dictionary format being parsed.

§field: &'static str

Name of the field being parsed.

§offset: usize

Byte offset of the invalid value.

§byte: u8

Invalid byte value.

§

InvalidCompression

A compressed data section could not be decoded.

Fields

§format: Format

Dictionary format being parsed.

§offset: usize

Byte offset of the compressed section in the source file.

§status: i32

Numeric zlib return status.

§

InvalidOffset

A declared byte offset was outside its valid section.

Fields

§format: Format

Dictionary format being parsed.

§field: &'static str

Name of the offset field.

§offset: usize

Declared byte offset.

§minimum: usize

Smallest valid byte offset.

§maximum: usize

Largest valid byte offset.

§

SizeMismatch

A decoded section size disagreed with the source declaration.

Fields

§format: Format

Dictionary format being parsed.

§field: &'static str

Name of the measured section.

§expected: u64

Size declared by the source.

§actual: u64

Size produced while parsing.

§

AllocationFailed

Memory for a declared section could not be reserved.

Fields

§format: Format

Dictionary format being parsed.

§field: &'static str

Name of the allocation target.

§requested: usize

Number of items requested.

§source: TryReserveError

Underlying allocation error.

§

InvalidCount

A declared count cannot fit in the remaining input.

Fields

§format: Format

Dictionary format being parsed.

§field: &'static str

Name of the count field.

§count: u64

Declared count.

§maximum: u64

Maximum count possible from the remaining bytes.

§

DuplicateCodeIndex

A code table contains the same identifier more than once.

Fields

§format: Format

Dictionary format being parsed.

§index: u64

Duplicate code identifier.

§

InvalidCodeIndex

A dictionary entry refers to an identifier absent from its code table.

Fields

§format: Format

Dictionary format being parsed.

§index: u64

Unknown code identifier.

§offset: usize

Byte offset of the reference.

§

InvalidCodeComponent

A component of an encoded syllable was outside its lookup table.

Fields

§format: Format

Dictionary format being parsed.

§field: &'static str

Component lookup table, such as initial or final.

§index: u64

Invalid lookup-table index.

§offset: usize

Byte offset of the invalid index.

§

InvalidRecordHeader

A record header did not match any supported layout.

Fields

§format: Format

Dictionary format being parsed.

§field: &'static str

Kind of record whose header was invalid.

§offset: usize

Byte offset of the record header.

§found: Vec<u8>

Header bytes found in the input.

§

InvalidExtensionLength

A record field is shorter than the format requires.

Fields

§format: Format

Dictionary format being parsed.

§field: &'static str

Name of the extension field.

§offset: usize

Byte offset of the length field.

§length: usize

Declared extension length.

§minimum: usize

Minimum length required by the format.

§

CountMismatch

A parsed item count disagrees with its declared count.

Fields

§format: Format

Dictionary format being parsed.

§field: &'static str

Name of the counted item.

§expected: u64

Count declared by the source.

§actual: u64

Number of items actually parsed.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

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