[][src]Trait hexutil::FromHex

pub trait FromHex: FromHexCore {
    fn from_hex(buf: &[u8]) -> Result<Self, FromHexError> { ... }
}

A type that can be created from a hexadecimal representation.

Provided methods

fn from_hex(buf: &[u8]) -> Result<Self, FromHexError>

Try to create an instance of this type from a hexadeccimal representation.

struct Test(u16);

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

let test = Test::from_hex(b"3412").unwrap();
assert_eq!(test, Test(0x1234));
Loading content...

Implementors

Loading content...