# Trait rustc_serialize::base64::FromBase64 [−] [src]

    pub trait FromBase64 {
        fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error>;
    }

A trait for converting from base64 encoded values.

## Required Methods

### `fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error>`

Converts the value of `self`, interpreted as base64 encoded data, into an owned vector of bytes, returning the vector.

## Implementations on Foreign Types

### `impl FromBase64 for str`
[src]

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

Convert any base64 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 base64 and back.

    extern crate rustc_serialize;
    use rustc_serialize::base64::{ToBase64, FromBase64, STANDARD};

    fn main () {
        let hello_str = b"Hello, World".to_base64(STANDARD);
        println!("base64 output: {}", hello_str);
        let res = hello_str.from_base64();
        if res.is_ok() {
          let opt_bytes = String::from_utf8(res.unwrap());
          if opt_bytes.is_ok() {
            println!("decoded from base64: {:?}", opt_bytes.unwrap());
          }
        }
    }

### `impl FromBase64 for [u8]`
[src]

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

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

#### `fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error>`
[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`)