# Trait rustc_serialize::Decodable [−] [src]

    pub trait Decodable: Sized {
        fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error>;
    }

Trait for deserializing a type.

This can be implemented for custom data types to allow them to be decoded with `Decoder` implementations. Most of Rust's built-in or standard data types (like `i32` and `Vec<T>`) have `Decodable` implementations provided by this module.

Note that, in general, you should let the compiler implement this for you by using the `derive(RustcDecodable)` attribute.

# Examples

    extern crate rustc_serialize;

    #[derive(RustcDecodable)]
    struct Point {
        x: i32,
        y: i32,
    }

This generates code equivalent to:

    extern crate rustc_serialize;
    use rustc_serialize::Decodable;
    use rustc_serialize::Decoder;

    struct Point {
        x: i32,
        y: i32,
    }

    impl Decodable for Point {
        fn decode<D: Decoder>(d: &mut D) -> Result<Point, D::Error> {
            d.read_struct("Point", 2, |d| {
                let x = try!(d.read_struct_field("x", 0, |d| { d.read_i32() }));
                let y = try!(d.read_struct_field("y", 1, |d| { d.read_i32() }));
                Ok(Point{ x: x, y: y })
            })
        }
    }

## Required Methods

### `fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error>`

Deserialize a value using a `Decoder`.

## Implementations on Foreign Types

### `impl Decodable for usize`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<usize, D::Error>`
[src]

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

#### `fn decode<D: Decoder>(d: &mut D) -> Result<u8, D::Error>`
[src]

### `impl Decodable for u16`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<u16, D::Error>`
[src]

### `impl Decodable for u32`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<u32, D::Error>`
[src]

### `impl Decodable for u64`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<u64, D::Error>`
[src]

### `impl Decodable for isize`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<isize, D::Error>`
[src]

### `impl Decodable for i8`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<i8, D::Error>`
[src]

### `impl Decodable for i16`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<i16, D::Error>`
[src]

### `impl Decodable for i32`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<i32, D::Error>`
[src]

### `impl Decodable for i64`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<i64, D::Error>`
[src]

### `impl Decodable for String`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<String, D::Error>`
[src]

### `impl Decodable for f32`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<f32, D::Error>`
[src]

### `impl Decodable for f64`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<f64, D::Error>`
[src]

### `impl Decodable for bool`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<bool, D::Error>`
[src]

### `impl Decodable for char`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<char, D::Error>`
[src]

### `impl Decodable for ()`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<(), D::Error>`
[src]

### `impl<T: Decodable> Decodable for Box<T>`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<Box<T>, D::Error>`
[src]

### `impl<T: Decodable> Decodable for Box<[T]>`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<Box<[T]>, D::Error>`
[src]

### `impl<T: Decodable> Decodable for Rc<T>`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<Rc<T>, D::Error>`
[src]

### `impl<'a, T: ?Sized> Decodable for Cow<'a, T> where
T: ToOwned,
T::Owned: Decodable,`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<Cow<'static, T>, D::Error>`
[src]

### `impl<T: Decodable> Decodable for Vec<T>`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<Vec<T>, D::Error>`
[src]

### `impl<T: Decodable> Decodable for Option<T>`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<Option<T>, D::Error>`
[src]

### `impl<T: Decodable, E: Decodable> Decodable for Result<T, E>`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<Result<T, E>, D::Error>`
[src]

### `impl<T> Decodable for PhantomData<T>`
[src]

#### `fn decode<D: Decoder>(_d: &mut D) -> Result<PhantomData<T>, D::Error>`
[src]

### `impl<T0: Decodable, T1: Decodable, T2: Decodable, T3: Decodable, T4: Decodable, T5: Decodable, T6: Decodable, T7: Decodable, T8: Decodable, T9: Decodable, T10: Decodable, T11: Decodable> Decodable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)`
[src]

#### `fn decode<D: Decoder>(
d: &mut D
) -> Result<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11), D::Error>`
[src]

### `impl<T1: Decodable, T2: Decodable, T3: Decodable, T4: Decodable, T5: Decodable, T6: Decodable, T7: Decodable, T8: Decodable, T9: Decodable, T10: Decodable, T11: Decodable> Decodable for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)`
[src]

#### `fn decode<D: Decoder>(
d: &mut D
) -> Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11), D::Error>`
[src]

### `impl<T2: Decodable, T3: Decodable, T4: Decodable, T5: Decodable, T6: Decodable, T7: Decodable, T8: Decodable, T9: Decodable, T10: Decodable, T11: Decodable> Decodable for (T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)`
[src]

#### `fn decode<D: Decoder>(
d: &mut D
) -> Result<(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11), D::Error>`
[src]

### `impl<T3: Decodable, T4: Decodable, T5: Decodable, T6: Decodable, T7: Decodable, T8: Decodable, T9: Decodable, T10: Decodable, T11: Decodable> Decodable for (T3, T4, T5, T6, T7, T8, T9, T10, T11)`
[src]

#### `fn decode<D: Decoder>(
d: &mut D
) -> Result<(T3, T4, T5, T6, T7, T8, T9, T10, T11), D::Error>`
[src]

### `impl<T4: Decodable, T5: Decodable, T6: Decodable, T7: Decodable, T8: Decodable, T9: Decodable, T10: Decodable, T11: Decodable> Decodable for (T4, T5, T6, T7, T8, T9, T10, T11)`
[src]

#### `fn decode<D: Decoder>(
d: &mut D
) -> Result<(T4, T5, T6, T7, T8, T9, T10, T11), D::Error>`
[src]

### `impl<T5: Decodable, T6: Decodable, T7: Decodable, T8: Decodable, T9: Decodable, T10: Decodable, T11: Decodable> Decodable for (T5, T6, T7, T8, T9, T10, T11)`
[src]

#### `fn decode<D: Decoder>(
d: &mut D
) -> Result<(T5, T6, T7, T8, T9, T10, T11), D::Error>`
[src]

### `impl<T6: Decodable, T7: Decodable, T8: Decodable, T9: Decodable, T10: Decodable, T11: Decodable> Decodable for (T6, T7, T8, T9, T10, T11)`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<(T6, T7, T8, T9, T10, T11), D::Error>`
[src]

### `impl<T7: Decodable, T8: Decodable, T9: Decodable, T10: Decodable, T11: Decodable> Decodable for (T7, T8, T9, T10, T11)`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<(T7, T8, T9, T10, T11), D::Error>`
[src]

### `impl<T8: Decodable, T9: Decodable, T10: Decodable, T11: Decodable> Decodable for (T8, T9, T10, T11)`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<(T8, T9, T10, T11), D::Error>`
[src]

### `impl<T9: Decodable, T10: Decodable, T11: Decodable> Decodable for (T9, T10, T11)`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<(T9, T10, T11), D::Error>`
[src]

### `impl<T10: Decodable, T11: Decodable> Decodable for (T10, T11)`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<(T10, T11), D::Error>`
[src]

### `impl<T11: Decodable> Decodable for (T11,)`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<(T11,), D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 32]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 32], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 31]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 31], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 30]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 30], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 29]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 29], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 28]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 28], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 27]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 27], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 26]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 26], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 25]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 25], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 24]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 24], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 23]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 23], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 22]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 22], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 21]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 21], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 20]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 20], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 19]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 19], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 18]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 18], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 17]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 17], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 16]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 16], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 15]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 15], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 14]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 14], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 13]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 13], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 12]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 12], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 11]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 11], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 10]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 10], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 9]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 9], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 8]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 8], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 7]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 7], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 6]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 6], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 5]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 5], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 4]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 4], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 3]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 3], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 2]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 2], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 1]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 1], D::Error>`
[src]

### `impl<T: Decodable> Decodable for [T; 0]`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<[T; 0], D::Error>`
[src]

### `impl Decodable for PathBuf`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<PathBuf, D::Error>`
[src]

### `impl<T: Decodable + Copy> Decodable for Cell<T>`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<Cell<T>, D::Error>`
[src]

### `impl<T: Decodable> Decodable for RefCell<T>`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<RefCell<T>, D::Error>`
[src]

### `impl<T: Decodable + Send + Sync> Decodable for Arc<T>`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<Arc<T>, D::Error>`
[src]

### `impl<T: Decodable> Decodable for LinkedList<T>`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<LinkedList<T>, D::Error>`
[src]

### `impl<T: Decodable> Decodable for VecDeque<T>`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<VecDeque<T>, D::Error>`
[src]

### `impl<K: Decodable + Ord, V: Decodable> Decodable for BTreeMap<K, V>`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<BTreeMap<K, V>, D::Error>`
[src]

### `impl<T: Decodable + Ord> Decodable for BTreeSet<T>`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<BTreeSet<T>, D::Error>`
[src]

### `impl<K, V> Decodable for HashMap<K, V> where
K: Decodable + Hash + Eq,
V: Decodable,`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<HashMap<K, V>, D::Error>`
[src]

### `impl<T> Decodable for HashSet<T> where
T: Decodable + Hash + Eq,`
[src]

#### `fn decode<D: Decoder>(d: &mut D) -> Result<HashSet<T>, D::Error>`
[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`)