Skip to main content

DecodeError

Enum DecodeError 

Source
pub enum DecodeError {
Show 25 variants Io(Error), UnexpectedEof, InvalidCbor { reason: String, }, NonCanonicalEncoding { major_type: u8, additional_info: u8, value: u64, }, UnsupportedTag { tag: u64, }, MapKeyNotString, InvalidCid { reason: String, }, InvalidCidContent, InvalidFloat, UnsupportedSimpleValue { value: u8, }, IndefiniteLengthNotSupported, TypeMismatch { expected: &'static str, found: String, }, MaxDepthExceeded { depth: usize, max: usize, }, AllocationExceeded { size: usize, max: usize, }, InvalidUtf8(FromUtf8Error), MapKeysNotSorted, ReservedAdditionalInfo { value: u8, }, Deserialization(String), TrailingData, NonCanonicalFloat, DuplicateMapKey, FloatsNotAllowed, IntegerOutOfRange { value: String, }, ArrayTooLarge { count: usize, max: usize, }, MapTooLarge { count: usize, max: usize, },
}
Expand description

Errors that can occur during DAG-CBOR decoding

Variants§

§

Io(Error)

I/O error during reading

§

UnexpectedEof

Unexpected end of input

§

InvalidCbor

Invalid CBOR major type

Fields

§reason: String

The reason the CBOR is invalid

§

NonCanonicalEncoding

Non-canonical encoding in strict mode

Fields

§major_type: u8

The major type of the non-canonical encoding

§additional_info: u8

The additional info byte

§value: u64

The decoded value

§

UnsupportedTag

Unsupported CBOR tag (only tag 42 allowed)

Fields

§tag: u64

The unsupported tag number

§

MapKeyNotString

Map key is not a string (DAG-CBOR requirement)

§

InvalidCid

Invalid CID encoding

Fields

§reason: String

The reason the CID is invalid

§

InvalidCidContent

CID tag not followed by byte string

§

InvalidFloat

Invalid float value (NaN or Infinity)

§

UnsupportedSimpleValue

Invalid simple value (only false, true, null allowed)

Fields

§value: u8

The unsupported simple value

§

IndefiniteLengthNotSupported

Indefinite length not supported

§

TypeMismatch

Type mismatch during deserialization

Fields

§expected: &'static str

The expected type

§found: String

The found type

§

MaxDepthExceeded

Maximum nesting depth exceeded

Fields

§depth: usize

The current depth

§max: usize

The maximum allowed depth

§

AllocationExceeded

Allocation limit exceeded

Fields

§size: usize

The requested allocation size

§max: usize

The maximum allowed size

§

InvalidUtf8(FromUtf8Error)

Invalid UTF-8 in text string

§

MapKeysNotSorted

Non-canonical map key ordering in strict mode

§

ReservedAdditionalInfo

Reserved additional info value (28-30)

Fields

§value: u8

The reserved value

§

Deserialization(String)

Deserialization error from serde

§

TrailingData

Trailing data after top-level object

§

NonCanonicalFloat

Non-canonical float encoding (not 64-bit)

§

DuplicateMapKey

Duplicate map key detected

§

FloatsNotAllowed

Float values not allowed (no_floats config)

§

IntegerOutOfRange

Integer out of i64 range (int64_range_only config)

Fields

§value: String

The value that was out of range

§

ArrayTooLarge

Array exceeds maximum element count

Fields

§count: usize

Actual array length

§max: usize

Maximum allowed length

§

MapTooLarge

Map exceeds maximum entry count

Fields

§count: usize

Actual map size

§max: usize

Maximum allowed size

Trait Implementations§

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, __formatter: &mut Formatter<'_>) -> Result

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

impl Error for DecodeError

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

Source§

fn custom<T: Display>(msg: T) -> Self

Raised when there is general error when deserializing a type. Read more
Source§

fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self

Raised when a Deserialize receives a type different from what it was expecting. Read more
Source§

fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self

Raised when a Deserialize receives a value of the right type but that is wrong for some other reason. Read more
Source§

fn invalid_length(len: usize, exp: &dyn Expected) -> Self

Raised when deserializing a sequence or map and the input data contains too many or too few elements. Read more
Source§

fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self

Raised when a Deserialize enum type received a variant with an unrecognized name.
Source§

fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self

Raised when a Deserialize struct type received a field with an unrecognized name.
Source§

fn missing_field(field: &'static str) -> Self

Raised when a Deserialize struct type expected to receive a required field with a particular name but that field was not present in the input.
Source§

fn duplicate_field(field: &'static str) -> Self

Raised when a Deserialize struct type received more than one of the same field.
Source§

impl From<DecodeError> for CarError

Source§

fn from(err: DecodeError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for DecodeError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<FromUtf8Error> for DecodeError

Source§

fn from(source: FromUtf8Error) -> Self

Converts to this type from the input type.

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> 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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.