Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 13 variants NotAContainer { found: Vec<u8>, expected: Vec<u8>, }, Truncated { what: &'static str, needed: u64, available: u64, }, UnsupportedFormat { major: u16, minor: u16, supported_major: u16, }, Reserved { what: &'static str, }, SectionOutOfBounds { id: u32, offset: u64, end: u64, file_len: u64, }, DuplicateSection { id: u32, }, MissingRecord(Tag), RepeatedRecord(Tag), UnsupportedRecord { tag: Tag, version: u16, }, DigestMismatch { what: String, expected: String, actual: String, }, Footer(Error), TooLarge { what: &'static str, needed: u64, }, Io { kind: ErrorKind, detail: String, },
}
Expand description

Why a container could not be read, or could not be trusted once it was read.

Every variant carries enough to put in a log line without going back to the file. An operator who gets one of these should be able to say what is wrong with the dataset without opening a hex editor, because the alternative is that they open a hex editor.

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

NotAContainer

The file does not start with the container magic.

Fields

§found: Vec<u8>

The first eight bytes of the file, or fewer if the file is shorter than that.

§expected: Vec<u8>

What those bytes should have been.

§

Truncated

The file starts correctly but ends somewhere unexpected.

Fields

§what: &'static str

Which part of the file ran out.

§needed: u64

How many bytes that part needed.

§available: u64

How many were there.

§

UnsupportedFormat

The container was written by a newer major version.

Fields

§major: u16

The major version in the file.

§minor: u16

The minor version in the file.

§supported_major: u16

The major version this build understands.

§

Reserved

A reserved field was not zero.

Reserved fields are the only place a future version can put a change that older readers must not ignore, so an older reader has to refuse rather than carry on.

Fields

§what: &'static str

Which part of the container the field is in.

§

SectionOutOfBounds

A section points somewhere that is not inside the payload area.

Fields

§id: u32

Which section.

§offset: u64

Where it claims to start.

§end: u64

Where it claims to end, saturated at u64::MAX.

§file_len: u64

How long the file actually is.

§

DuplicateSection

Two sections claim the same identifier.

Fields

§id: u32

The repeated identifier.

§

MissingRecord(Tag)

A required footer record was missing.

§

RepeatedRecord(Tag)

A footer record appeared more times than it is allowed to.

§

UnsupportedRecord

A known footer record was written at a version this build does not read.

Fields

§tag: Tag

Which record.

§version: u16

The version on it.

§

DigestMismatch

A digest did not match the bytes it covers.

Fields

§what: String

Which digest.

§expected: String

What the container claims.

§actual: String

What the bytes actually hash to.

§

Footer(Error)

The bytes inside the footer did not parse.

§

TooLarge

Something in the container is bigger than this build can address.

On a 64 bit host this cannot happen. It is here so that a 32 bit host gets a sentence instead of a panic.

Fields

§what: &'static str

Which part of the container.

§needed: u64

How many bytes it asked for.

§

Io

Writing a container out did not work.

Only crate::Builder::build_into produces this. Reading never touches a file: a container is parsed from bytes somebody else fetched, which is what lets the same parser run against a mapped file, a buffer and a fuzzer’s input.

The kind is kept and the error itself is not, because this enum compares by value and std::io::Error does not. The kind is the part anybody branches on anyway, and the text is there for whoever reads the message.

Fields

§kind: ErrorKind

What went wrong, as the operating system classified it.

§detail: String

What it said.

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Error

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 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 Eq for Error

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

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Error

Source§

fn eq(&self, other: &Error) -> 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 Error

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

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