Enum serde_bencode::error::Error
source · pub enum Error {
IoError(Error),
InvalidType(String),
InvalidValue(String),
InvalidLength(String),
UnknownVariant(String),
UnknownField(String),
MissingField(String),
DuplicateField(String),
Custom(String),
EndOfStream,
}
Expand description
Represents all possible errors which can occur when serializing or deserializing bencode.
Variants§
IoError(Error)
Raised when an IO error occurred.
InvalidType(String)
Raised when the value being deserialized is of the incorrect type.
InvalidValue(String)
Raised when the value being deserialized is of the right type, but is wrong for some other reason. For example, this error may occur when deserializing to a String but the input data is not valid UTF-8.
InvalidLength(String)
Raised when deserializing a sequence or map, but the input data is the wrong length.
UnknownVariant(String)
Raised when deserializing an enum, but the variant has an unrecognized name.
UnknownField(String)
Raised when deserializing a struct, but there was a field which does not match any of the expected fields.
MissingField(String)
Raised when deserializing a struct, but there was a field which was expected but not present.
DuplicateField(String)
Raised when deserializing a struct, but there is more than one field with the same name.
Custom(String)
Catchall for any other kind of error.
EndOfStream
Unexpected end of input stream.
Trait Implementations§
source§impl Error for Error
impl Error for Error
source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
source§impl Error for Error
impl Error for Error
source§fn custom<T: Display>(msg: T) -> Self
fn custom<T: Display>(msg: T) -> Self
source§fn invalid_type(unexpected: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_type(unexpected: Unexpected<'_>, exp: &dyn Expected) -> Self
Deserialize
receives a type different from what it was
expecting. Read moresource§fn invalid_value(unexpected: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_value(unexpected: 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(field: &str, expected: &'static [&'static str]) -> Self
fn unknown_variant(field: &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.