Trait serialize::hex::FromHex
[−]
[src]
pub trait FromHex {
fn from_hex(&self) -> Result<Vec<u8>, FromHexError>;
}🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
A trait for converting hexadecimal encoded values
Required Methods
fn from_hex(&self) -> Result<Vec<u8>, FromHexError>
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
Converts the value of self, interpreted as hexadecimal encoded data,
into an owned vector of bytes, returning the vector.
Implementations on Foreign Types
impl FromHex for str[src]
fn from_hex(&self) -> Result<Vec<u8>, FromHexError>[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
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.
Examples
This converts a string literal to hexadecimal and back.
#![feature(rustc_private)] extern crate serialize; use serialize::hex::{FromHex, ToHex}; fn main () { let hello_str = "Hello, World".as_bytes().to_hex(); println!("{}", hello_str); let bytes = hello_str.from_hex().unwrap(); println!("{:?}", bytes); let result_str = String::from_utf8(bytes).unwrap(); println!("{}", result_str); }Run