Skip to main content

FromHexStr

Trait FromHexStr 

Source
pub trait FromHexStr {
    // Required method
    fn try_from_hex(&self) -> Result<Vec<u8>, HexError>;
}
Expand description

Extension trait for decoding hex strings to byte data.

Input should be treated as untrusted; use fallible methods.

§Security Warning

Decoding input from untrusted sources should use fallible try_ methods. Invalid input may indicate tampering or errors.

§Example

use secure_gate::FromHexStr;
let hex_string = "424344";
let bytes = hex_string.try_from_hex().unwrap();
// bytes is now Vec<u8>: [66, 66, 66]

Required Methods§

Source

fn try_from_hex(&self) -> Result<Vec<u8>, HexError>

Fallibly decode a hex string to bytes.

Implementors§

Source§

impl<T: AsRef<str> + ?Sized> FromHexStr for T

Available on crate feature encoding-hex only.