Enum bencodex::codec::decode::DecodeError [−][src]
pub enum DecodeError {
InvalidBencodexValueError,
UnexpectedTokenError {
token: u8,
point: usize,
},
}
Expand description
The error type which is returned from decoding a Bencodex value through Decode::decode
.
Variants
This should be used when it failed to decode. In future, it will be separated more and more.
This should be used when it failed to decode because there is unexpected token appeared while decoding.
Example
For example, The encoded bytes of BencodexValue::Number
are formed as ‘i{}e’ (e.g., ‘i0e’, ‘i2147483647e’). If it is not satisified, it should be result through inside Err
.
use bencodex::{ Decode, DecodeError };
// v -- should be b'0' ~ b'9' digit.
let vec = vec![b'i', b':', b'e'];
let error = vec.decode().unwrap_err();
let expected_error = DecodeError::UnexpectedTokenError {
token: b':',
point: 1,
};
assert_eq!(expected_error, error);
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.