serde_cbor

Struct Error

Source
pub struct Error(/* private fields */);
Expand description

This type represents all possible errors that can occur when serializing or deserializing CBOR data.

Implementations§

Source§

impl Error

Source

pub fn offset(&self) -> u64

The byte offset at which the error occurred.

Source

pub fn io() -> Error

Creates an error signalling that the underlying Read encountered an I/O error.

Source

pub fn scratch_too_small(offset: u64) -> Error

Creates an error signalling that the scratch buffer was too small to fit the data.

Source

pub fn message<T: Display>(_msg: T) -> Error

Creates an error with a custom message.

Note: When the “std” feature is disabled, the message will be discarded.

Source

pub fn eof(offset: u64) -> Error

Creates an error signalling that the underlying read encountered an end of input.

Source

pub fn classify(&self) -> Category

Categorizes the cause of this error.

Source

pub fn is_io(&self) -> bool

Returns true if this error was caused by a failure to read or write bytes on an IO stream.

Source

pub fn is_syntax(&self) -> bool

Returns true if this error was caused by input that was not syntactically valid CBOR.

Source

pub fn is_data(&self) -> bool

Returns true if this error was caused by data that was semantically incorrect.

Source

pub fn is_eof(&self) -> bool

Returns true if this error was caused by prematurely reaching the end of the input data.

Source

pub fn is_scratch_too_small(&self) -> bool

Returns true if this error was caused by the scratch buffer being too small.

Note this being true implies that is_io() is also true.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

Source§

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

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

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

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

Source§

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

Used when a Serialize implementation encounters any error while serializing a type. Read more
Source§

impl From<Error> for Error

Source§

fn from(_: Error) -> Error

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnwindSafe for Error

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

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 16 bytes