Skip to main content

DecodeError

Enum DecodeError 

Source
pub enum DecodeError {
Show 13 variants UnknownKey(String), MissingField(&'static str), WrongArity { expected: u64, found: u64, }, IndefiniteLength, DuplicateKey, NonMinimalHead, UnsortedMapKeys, UnexpectedType { expected: &'static str, found: String, }, InvalidLength { field: &'static str, expected: usize, found: usize, }, BadLiteral { expected: &'static str, found: String, }, TrailingBytes { consumed: usize, total: usize, }, Constraint(&'static str), Malformed(String),
}
Expand description

Failure to decode a wire value.

Decoding is strict by design: it rejects unknown map keys, wrong map arity, indefinite-length items (RFC 8949 4.2 core deterministic encoding requires definite lengths), non-minimal head widths, map keys out of CDE order (including duplicates), floats, tags, non-32-byte device-ids, bad enum literals, and trailing bytes after a top-level item — so any input that decodes also re-encodes to the identical bytes.

Variants§

§

UnknownKey(String)

A map key that no CDDL rule in the corresponding family defines.

§

MissingField(&'static str)

A mandatory field of a map is absent.

§

WrongArity

A map or array head declared a different arity than the rule allows.

Fields

§expected: u64
§found: u64
§

IndefiniteLength

An indefinite-length item where CDE requires a definite one.

§

DuplicateKey

A duplicate key within a single map.

§

NonMinimalHead

A head (integer, string, bytes, map, or array) not in shortest CBOR form, which RFC 8949 4.2.1 core deterministic encoding requires.

§

UnsortedMapKeys

Map keys not in RFC 8949 4.2.1 core deterministic order (encoded-length first, then bytewise).

§

UnexpectedType

A value of the wrong CBOR type or shape for the field.

Fields

§expected: &'static str
§found: String
§

InvalidLength

A fixed-size field (e.g. device-id) of the wrong byte length.

Fields

§field: &'static str
§expected: usize
§found: usize
§

BadLiteral

An enum literal that is not part of the closed union.

Fields

§expected: &'static str
§found: String
§

TrailingBytes

Bytes remained after the top-level item.

Fields

§consumed: usize
§total: usize
§

Constraint(&'static str)

A bool/uint/int constraint from the CDDL failed on the decoded value.

§

Malformed(String)

Anything else, including malformed CBOR from the underlying decoder.

Implementations§

Source§

impl DecodeError

Source

pub fn from_minicbor(err: Error) -> Self

Map an underlying minicbor decode error into a DecodeError.

Trait Implementations§

Source§

impl Clone for DecodeError

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 Debug for DecodeError

Source§

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

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

impl Display for DecodeError

Source§

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

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

impl Eq for DecodeError

Source§

impl Error for DecodeError

1.30.0 · 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

Replaced by Error::source.
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 PartialEq for DecodeError

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 DecodeError

Auto Trait Implementations§

§

impl Forget for DecodeError

§

impl Freeze for DecodeError
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, &'static str: Freeze,

§

impl Move for DecodeError

§

impl RefUnwindSafe for DecodeError

§

impl Send for DecodeError
where RawVecInner: Send, &'static str: Send,

§

impl Sync for DecodeError
where RawVecInner: Sync,

§

impl Unpin for DecodeError
where *const u8 is !null: Unpin, &'static str: Unpin,

§

impl UnsafeUnpin for DecodeError

§

impl UnwindSafe for DecodeError
where RawVecInner: UnwindSafe, &'static str: UnwindSafe,

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.