pub enum DecodeVariableLengthBytesError {
InvalidChar(InvalidCharError),
OddLengthString(OddLengthStringError),
}Expand description
Error returned when hex decoding a hex string with variable length.
This represents the first error encountered during decoding, however we may add other remaining ones in the future.
This error differs from DecodeFixedLengthBytesError in that the number of bytes is only known
at run time - e.g. when decoding Vec<u8>.
Variants§
InvalidChar(InvalidCharError)
Non-hexadecimal character.
OddLengthString(OddLengthStringError)
Purported hex string had odd (not even) length.
Implementations§
Source§impl DecodeVariableLengthBytesError
impl DecodeVariableLengthBytesError
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 DecodeVariableLengthBytesError
impl Clone for DecodeVariableLengthBytesError
Source§fn clone(&self) -> DecodeVariableLengthBytesError
fn clone(&self) -> DecodeVariableLengthBytesError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Eq for DecodeVariableLengthBytesError
Source§impl Error for DecodeVariableLengthBytesError
Available on crate feature std, or rust_version=>= 1.81.0 and crate feature newer-rust-version only.
impl Error for DecodeVariableLengthBytesError
std, or rust_version=>= 1.81.0 and crate feature newer-rust-version only.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
use the Display impl or to_string()