pub struct InvalidCharError { /* private fields */ }Expand description
Invalid hex character.
Implementations§
Source§impl InvalidCharError
impl InvalidCharError
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.
Important: if you have DecodeVariableLengthBytesError or DecodeFixedLengthBytesError you
should call the method on them - do not match them and manually call this method. Doing
so may lead to broken behavior in the future.
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 InvalidCharError
impl Clone for InvalidCharError
Source§fn clone(&self) -> InvalidCharError
fn clone(&self) -> InvalidCharError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InvalidCharError
impl Debug for InvalidCharError
Source§impl Display for InvalidCharError
Note that the implementation displays position as 1-based instead of 0-based to be more
suitable to end users who might be non-programmers.
impl Display for InvalidCharError
Note that the implementation displays position as 1-based instead of 0-based to be more suitable to end users who might be non-programmers.
Source§impl Error for InvalidCharError
Available on crate feature std, or crate feature newer-rust-version and rust_version=>= 1.81.0 only.
impl Error for InvalidCharError
std, or crate feature newer-rust-version and rust_version=>= 1.81.0 only.