pub trait FromHex: Sized {
type Error;
// Required method
fn from_hex<T: AsRef<[u8]>>(hex: T) -> Result<Self, Self::Error>;
}
Expand description
Types that can be decoded from a hex string.
This trait is implemented for Vec<u8>
and small u8
-arrays.
§Example
use hex::FromHex;
match Vec::from_hex("48656c6c6f20776f726c6421") {
Ok(vec) => {
for b in vec {
println!("{}", b as char);
}
}
Err(e) => {
// Deal with the error ...
}
}
Required Associated Types§
Required Methods§
Object Safety§
This trait is not object safe.