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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Error for DecodeVariableLengthBytesError
Available on crate feature std, or crate feature newer-rust-version and rust_version=>= 1.81.0 only.
impl Error for DecodeVariableLengthBytesError
std, or crate feature newer-rust-version and rust_version=>= 1.81.0 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
Source§impl From<Infallible> for DecodeVariableLengthBytesError
impl From<Infallible> for DecodeVariableLengthBytesError
Source§fn from(never: Infallible) -> Self
fn from(never: Infallible) -> Self
Source§impl From<InvalidCharError> for DecodeVariableLengthBytesError
impl From<InvalidCharError> for DecodeVariableLengthBytesError
Source§fn from(e: InvalidCharError) -> Self
fn from(e: InvalidCharError) -> Self
Source§impl From<OddLengthStringError> for DecodeVariableLengthBytesError
impl From<OddLengthStringError> for DecodeVariableLengthBytesError
Source§fn from(e: OddLengthStringError) -> Self
fn from(e: OddLengthStringError) -> Self
Source§impl PartialEq for DecodeVariableLengthBytesError
impl PartialEq for DecodeVariableLengthBytesError
Source§fn eq(&self, other: &DecodeVariableLengthBytesError) -> bool
fn eq(&self, other: &DecodeVariableLengthBytesError) -> bool
self and other values to be equal, and is used by ==.