Skip to main content

DecodeErrorKind

Enum DecodeErrorKind 

Source
#[non_exhaustive]
pub enum DecodeErrorKind {
Show 15 variants UnexpectedEnd, BadMagic, UnsupportedVersion(u32), ReservedFlags(u32), SectionOutOfOrder { expected: u32, found: u32, }, SectionLength(u32), TrailingBytes, LimitExceeded(Limit), InvalidUtf8, InvalidTag { what: &'static str, tag: u8, }, InvalidChar(u32), ConstForwardRef { index: u32, child: u32, }, HookOrder, DebugCount { expected: u32, found: u32, }, Inst(InstError),
}
Expand description

What is wrong with the input; see DecodeError.

§Examples

use bytecode_lang::{decode, DecodeErrorKind};

assert_eq!(decode(b"LS").unwrap_err().kind(), &DecodeErrorKind::UnexpectedEnd);
assert_eq!(decode(b"MZ\0\0\x01\0\0\0\0\0\0\0").unwrap_err().kind(), &DecodeErrorKind::BadMagic);

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

UnexpectedEnd

The input ends before a value it promises.

§

BadMagic

The first four bytes are not LSB\0.

§

UnsupportedVersion(u32)

The format version is not one this decoder implements.

§

ReservedFlags(u32)

The header’s reserved flags are not zero.

§

SectionOutOfOrder

A section id is not the next one in the fixed order.

Fields

§expected: u32

The id that should come next.

§found: u32

The id found.

§

SectionLength(u32)

A section’s contents do not fill exactly its declared length.

§

TrailingBytes

Bytes follow the last section.

§

LimitExceeded(Limit)

A budget was exceeded.

§

InvalidUtf8

A string is not valid UTF-8.

§

InvalidTag

A tag byte names nothing (what says which kind of tag).

Fields

§what: &'static str

The kind of tag: "value type", "type", "constant", …

§tag: u8

The byte found.

§

InvalidChar(u32)

A char constant is not a Unicode scalar value.

§

ConstForwardRef

An aggregate constant refers to itself or a later constant.

Fields

§index: u32

The aggregate.

§child: u32

The offending element.

§

HookOrder

Hook bindings are not in strictly increasing hook order.

§

DebugCount

The debug section’s function count differs from the function section’s.

Fields

§expected: u32

Functions in the module.

§found: u32

Debug entries found.

§

Inst(InstError)

An instruction is malformed.

Trait Implementations§

Source§

impl Clone for DecodeErrorKind

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 DecodeErrorKind

Source§

impl Debug for DecodeErrorKind

Source§

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

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

impl Display for DecodeErrorKind

Source§

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

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

impl Eq for DecodeErrorKind

Source§

impl PartialEq for DecodeErrorKind

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 DecodeErrorKind

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.