pub enum DecodeFixedLengthBytesError {
InvalidChar(InvalidCharError),
InvalidLength(InvalidLengthError),
}Expand description
Error returned when hex decoding bytes whose length is known at compile time.
This error differs from DecodeVariableLengthBytesError in that the number of bytes is known at
compile time - e.g. when decoding to an array of bytes.
Variants§
InvalidChar(InvalidCharError)
Non-hexadecimal character.
InvalidLength(InvalidLengthError)
Tried to parse fixed-length hash from a string with the wrong length.
Implementations§
Source§impl DecodeFixedLengthBytesError
impl DecodeFixedLengthBytesError
Sourcepub fn offset(self, by_bytes: usize) -> Self
pub fn offset(self, by_bytes: usize) -> Self
Adds by_bytes to all character positions stored inside.
If you’re parsing a larger string that consists of multiple hex sub-strings and want to
return InvalidCharError you may need to use this function so that the callers of your
parsing function can tell the exact position where decoding failed relative to the start of
the string passed into your parsing function.
Note that this function has the standard Rust overflow behavior because you should only ever pass in the position of the parsed hex string relative to the start of the entire input. In that case overflow is impossible.
This method consumes and returns self so that calling it inside a closure passed into
Result::map_err is convenient.
Trait Implementations§
Source§impl Clone for DecodeFixedLengthBytesError
impl Clone for DecodeFixedLengthBytesError
Source§fn clone(&self) -> DecodeFixedLengthBytesError
fn clone(&self) -> DecodeFixedLengthBytesError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DecodeFixedLengthBytesError
impl Debug for DecodeFixedLengthBytesError
Source§impl Error for DecodeFixedLengthBytesError
Available on crate feature std, or crate feature newer-rust-version and rust_version=>= 1.81.0 only.
impl Error for DecodeFixedLengthBytesError
std, or crate feature newer-rust-version and rust_version=>= 1.81.0 only.