Trait FromHex
pub trait FromHex: Sized {
type Error;
// Required method
fn from_hex<T>(hex: T) -> Result<Self, Self::Error>
where T: AsRef<[u8]>;
}
Expand description
Types that can be decoded from a hex string.
This trait is implemented for Vec<u8>
and small u8
-arrays.
§Example
use const_hex::FromHex;
let buffer = <[u8; 12]>::from_hex("48656c6c6f20776f726c6421")?;
assert_eq!(buffer, *b"Hello world!");
Required Associated Types§
type Error
type Error
The associated error which can be returned from parsing.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.