#[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
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
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.
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
.
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)
serde
only.A generic serde error occurred
Implementations§
Source§impl EncodingError
impl EncodingError
pub fn validation_error<'a>(fmt: Arguments<'a>) -> Self
pub fn invalid_variant<V>(v: V) -> Self
Trait Implementations§
Source§impl Debug for EncodingError
impl Debug for EncodingError
Source§impl Display for EncodingError
impl Display for EncodingError
Source§impl Error for EncodingError
impl Error for EncodingError
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
Source§impl Error for EncodingError
impl Error for EncodingError
Source§impl Error for EncodingError
impl Error for EncodingError
Source§fn custom<Msg>(_msg: Msg) -> Selfwhere
Msg: Display,
fn custom<Msg>(_msg: Msg) -> Selfwhere
Msg: Display,
Source§fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
Deserialize
receives a type different from what it was
expecting. Read moreSource§fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
Deserialize
receives a value of the right type but that
is wrong for some other reason. Read moreSource§fn invalid_length(len: usize, exp: &dyn Expected) -> Self
fn invalid_length(len: usize, exp: &dyn Expected) -> Self
Source§fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
Deserialize
enum type received a variant with an
unrecognized name.Source§fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
Deserialize
struct type received a field with an
unrecognized name.Source§fn missing_field(field: &'static str) -> Self
fn missing_field(field: &'static str) -> Self
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
fn duplicate_field(field: &'static str) -> Self
Deserialize
struct type received more than one of the
same field.