#[non_exhaustive]pub enum Error {
Show 14 variants
Malformed,
NonDeterministic,
UnexpectedEof,
LengthTooLarge,
InvalidUtf8,
InvalidHex,
InvalidBase64,
IncompatibleType(DataType),
Overflow,
NegativeUnsigned,
Precision,
InvalidSimpleValue,
InvalidFormat,
InvalidValue,
}Expand description
Errors produced by this crate.
Errors fall into three categories:
Decoding errors are returned by Value::decode,
Value::read_from,
and Value::read_hex_from when the input is not valid deterministic
CBOR: Malformed, NonDeterministic,
UnexpectedEof, LengthTooLarge,
InvalidUtf8, InvalidHex, InvalidBase64.
Accessor errors are returned by the to_*, as_*, and into_*
methods on Value when the value does not match the requested type:
IncompatibleType, Overflow,
NegativeUnsigned, Precision,
InvalidSimpleValue.
Validation errors are returned during construction of typed helpers
like DateTime and EpochTime:
InvalidFormat, InvalidValue.
Error is Copy, Eq, Ord, and Hash, so it can be matched,
compared, and used as a map key without allocation. I/O errors are
handled separately by IoError, which wraps either an Error or
a std::io::Error. This separation keeps Error small and
Copy-able while still supporting streaming operations that can
fail with I/O problems.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Malformed
Binary CBOR data is structurally broken.
NonDeterministic
CBOR encoding is valid but not deterministic (non-shortest form, unsorted map keys, etc.).
UnexpectedEof
Input ended before a complete data item was read.
LengthTooLarge
Declared length exceeds addressable memory or reasonable size.
InvalidUtf8
Text string contains invalid UTF-8.
InvalidHex
Hex input contains invalid characters.
InvalidBase64
Base64 input contains invalid characters.
IncompatibleType(DataType)
Accessor called on a value of the wrong CBOR type.
Overflow
Integer does not fit in the target type.
NegativeUnsigned
Attempted to read a negative integer as an unsigned type.
Precision
Float conversion would lose precision.
InvalidSimpleValue
Simple value number is in the reserved range 24-31.
InvalidFormat
A text field had invalid syntax for its expected format.
InvalidValue
A value violates semantic constraints.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()