Trait ParseHex

Source
pub trait ParseHex {
    // Required method
    fn parse_hex<T: FromHex>(self) -> Result<T, FromHexError>;
}
Expand description

Parse a hexadecimal value.

struct Test(u16);

hexutil::impl_from_hex!(Test, 2, |data| Ok(Self(u16::from_le_bytes(data))));

let test: Test = "3412".parse_hex().unwrap();
assert_eq!(test, Test(0x1234));

Required Methods§

Source

fn parse_hex<T: FromHex>(self) -> Result<T, FromHexError>

Parse the hexadecimal string representation and create a value of type T.

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.

Implementations on Foreign Types§

Source§

impl ParseHex for &str

Source§

impl ParseHex for &[u8]

Implementors§