Enum EncodingError

Source
#[non_exhaustive]
pub enum EncodingError {
Show 15 variants IOError(ErrorKind), UnexpectedEnd, SeekError(SeekError), VarIntError, InvalidBool, StringError(StringError), MaxSizeExceeded { max: usize, requested: usize, }, InvalidVariant(Opaque), TooLarge { value: Opaque, requested_width: BitWidth, }, SignMismatch { expected: Signedness, got: Signedness, }, FlattenError(FlattenError), LockError, BorrowError(BorrowError), ValidationError(String), SerdeError(String),
}
Expand description

Represents any kind of error that can happen during encoding and decoding

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

IOError(ErrorKind)

Generic IO error

§

UnexpectedEnd

The end of the file or buffer was reached but more data was expected

§

SeekError(SeekError)

An error involving the seek operation occurred.

§

VarIntError

A var-int was malformed and could not be decoded

§

InvalidBool

A value other than 1 or 0 was read while decoding a bool

§

StringError(StringError)

An attempt was made to encode or decode a string, but something went wrong.

§

MaxSizeExceeded

Tried to write or read a usize greater than the max

Fields

§max: usize
§requested: usize
§

InvalidVariant(Opaque)

Tried to decode an unrecognized enum variant

§

TooLarge

Tried to squeeze a value into fewer bits than what is required to fully represent it.

Fields

§value: Opaque
§requested_width: BitWidth
§

SignMismatch

Expected to get a value with a specific signedness, but got one with the opposite. E.G. Expected an u8 but got an i8.

Fields

§expected: Signedness
§

FlattenError(FlattenError)

An attempt was made to flatten an option or result, but the inner value was unexpected. Example: #[ender(flatten: some)] applied on an Option containing the None variant

§

LockError

An attempt was made to lock a RefCell/Mutex/RwLock or similar, but it failed.

§

BorrowError(BorrowError)

A piece of data couldn’t be borrowed from the encoder. This is a recoverable error, meaning the decoding operation can be attempted again with a non-borrowing function.

§

ValidationError(String)

A #[ender(validate = ...)] check failed

§

SerdeError(String)

Available on crate feature serde only.

A generic serde error occurred

Implementations§

Source§

impl EncodingError

Source

pub fn validation_error<'a>(fmt: Arguments<'a>) -> Self

Source

pub fn invalid_variant<V>(v: V) -> Self
where Opaque: From<V>,

Trait Implementations§

Source§

impl Debug for EncodingError

Source§

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

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

impl Display for EncodingError

Source§

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

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

impl Error for EncodingError

Source§

fn kind(&self) -> ErrorKind

Get the kind of this error.
Source§

impl Error for EncodingError

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
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 EncodingError

Source§

fn custom<Msg>(_msg: Msg) -> Self
where Msg: Display,

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

impl Error for EncodingError

Source§

fn custom<Msg>(_msg: Msg) -> Self
where Msg: Display,

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<BorrowError> for EncodingError

Source§

fn from(value: BorrowError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for EncodingError

Source§

fn from(value: Error) -> Self

Converts to this type from the input type.
Source§

impl From<ErrorKind> for EncodingError

Source§

fn from(value: ErrorKind) -> Self

Converts to this type from the input type.
Source§

impl From<FlattenError> for EncodingError

Source§

fn from(value: FlattenError) -> Self

Converts to this type from the input type.
Source§

impl<T: Error> From<ReadExactError<T>> for EncodingError

Source§

fn from(value: ReadExactError<T>) -> Self

Converts to this type from the input type.
Source§

impl From<SeekError> for EncodingError

Source§

fn from(value: SeekError) -> Self

Converts to this type from the input type.
Source§

impl From<StringError> for EncodingError

Source§

fn from(value: StringError) -> 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> IntoResult<T> for T

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.