# Trait rustc_serialize::hex::FromHex [−] [src]

    pub trait FromHex {
        fn from_hex(&self) -> Result<Vec<u8>, FromHexError>;
    }

A trait for converting hexadecimal encoded values

## Required Methods

### `fn from_hex(&self) -> Result<Vec<u8>, FromHexError>`

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]

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_serialize;
    use rustc_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);
    }

### `impl<'a, T: ?Sized + FromHex> FromHex for &'a T`
[src]

#### `fn from_hex(&self) -> Result<Vec<u8>, FromHexError>`
[src]

## Implementors

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)