[−][src]Trait inhex::FromHex
A trait for converting hexadecimal encoded values
Required methods
fn from_hex<T>(&self) -> Result<T, FromHexError> where
T: FromIterator<u8>,
T: FromIterator<u8>,
Converts the value of self
, interpreted as hexadecimal encoded data,
into an owned value constructed from an iterator of bytes.
Implementations on Foreign Types
impl<'a, T> FromHex for &'a T where
T: FromHex + ?Sized,
[src]
T: FromHex + ?Sized,
fn from_hex<U>(&self) -> Result<U, FromHexError> where
U: FromIterator<u8>,
[src]
U: FromIterator<u8>,
impl FromHex for str
[src]
fn from_hex<T>(&self) -> Result<T, FromHexError> where
T: FromIterator<u8>,
[src]
T: FromIterator<u8>,
Convert any hexadecimal encoded string (literal, @
, &
, or ~
)
to the byte values it encodes.
You can use the String::from_utf8
function to turn a
Vec<u8>
into a string with characters corresponding to those values.
Example
This converts a string literal to hexadecimal and back.
extern crate rustc_hex; use rustc_hex::{FromHex, ToHex}; fn main () { let hello_str: String = "Hello, World".as_bytes().to_hex(); println!("{}", hello_str); let bytes: Vec<u8> = hello_str.from_hex().unwrap(); println!("{:?}", bytes); let result_str = String::from_utf8(bytes).unwrap(); println!("{}", result_str); }