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.
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.
InvalidLength
A fixed-size field (e.g. device-id) of the wrong byte length.
BadLiteral
An enum literal that is not part of the closed union.
TrailingBytes
Bytes remained after the top-level item.
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
impl DecodeError
Sourcepub fn from_minicbor(err: Error) -> Self
pub fn from_minicbor(err: Error) -> Self
Map an underlying minicbor decode error into a DecodeError.
Trait Implementations§
Source§impl Clone for DecodeError
impl Clone for DecodeError
Source§impl Debug for DecodeError
impl Debug for DecodeError
Source§impl Display for DecodeError
impl Display for DecodeError
impl Eq for DecodeError
Source§impl Error for DecodeError
impl Error for DecodeError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()