Decodable in rustc_serialize - Rust
Description: Trait for types that can be deserialized

Skip to main content

## Decodable

# Trait Decodable

Source

    pub trait Decodable<D: Decoder>: Sized {
        // Required method
        fn decode(d: &mut D) -> Self;
    }

Expand description

Trait for types that can be deserialized

This can be implemented using the `Decodable`, `TyDecodable` and `MetadataDecodable` macros.

- `Decodable` should be used in crates that don’t depend on `rustc_middle`.
- `MetadataDecodable` is used in `rustc_metadata` for types that contain `rustc_metadata::rmeta::Lazy`.
- `TyDecodable` should be used for types that are only serialized in crate metadata or the incremental cache. This is most types in `rustc_middle`.

## Required Methods§

Source

#### fn decode(d: &mut D) -> Self

## Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

## Implementations on Foreign Types§

Source§

### impl<'a> Decodable<MemDecoder<'a>> for Vec<u8>

Source§

#### fn decode(d: &mut MemDecoder<'a>) -> Self

Source§

### impl<D: Decoder> Decodable<D> for Cow<'_, str>

Source§

#### fn decode(d: &mut D) -> Cow<'static, str>

Source§

### impl<D: Decoder> Decodable<D> for bool

Source§

#### fn decode(d: &mut D) -> bool

Source§

### impl<D: Decoder> Decodable<D> for char

Source§

#### fn decode(d: &mut D) -> char

Source§

### impl<D: Decoder> Decodable<D> for i8

Source§

#### fn decode(d: &mut D) -> i8

Source§

### impl<D: Decoder> Decodable<D> for i16

Source§

#### fn decode(d: &mut D) -> i16

Source§

### impl<D: Decoder> Decodable<D> for i32

Source§

#### fn decode(d: &mut D) -> i32

Source§

### impl<D: Decoder> Decodable<D> for i64

Source§

#### fn decode(d: &mut D) -> i64

Source§

### impl<D: Decoder> Decodable<D> for i128

Source§

#### fn decode(d: &mut D) -> i128

Source§

### impl<D: Decoder> Decodable<D> for isize

Source§

#### fn decode(d: &mut D) -> isize

Source§

### impl<D: Decoder> Decodable<D> for !

Source§

#### fn decode(_d: &mut D) -> !

Source§

### impl<D: Decoder> Decodable<D> for u8

Source§

#### fn decode(d: &mut D) -> u8

Source§

### impl<D: Decoder> Decodable<D> for u16

Source§

#### fn decode(d: &mut D) -> u16

Source§

### impl<D: Decoder> Decodable<D> for u32

Source§

#### fn decode(d: &mut D) -> u32

Source§

### impl<D: Decoder> Decodable<D> for u64

Source§

#### fn decode(d: &mut D) -> u64

Source§

### impl<D: Decoder> Decodable<D> for u128

Source§

#### fn decode(d: &mut D) -> u128

Source§

### impl<D: Decoder> Decodable<D> for ()

Source§

#### fn decode(_: &mut D)

Source§

### impl<D: Decoder> Decodable<D> for usize

Source§

#### fn decode(d: &mut D) -> usize

Source§

### impl<D: Decoder> Decodable<D> for String

Source§

#### fn decode(d: &mut D) -> String

Source§

### impl<D: Decoder> Decodable<D> for NonZero<u32>

Source§

#### fn decode(d: &mut D) -> Self

Source§

### impl<D: Decoder> Decodable<D> for PathBuf

Source§

#### fn decode(d: &mut D) -> PathBuf

Source§

### impl<D: Decoder> Decodable<D> for Hash64

Source§

#### fn decode(d: &mut D) -> Self

Source§

### impl<D: Decoder> Decodable<D> for Hash128

Source§

#### fn decode(d: &mut D) -> Self

Source§

### impl<D: Decoder, A: Array<Item: Decodable<D>>> Decodable<D> for SmallVec<A>

Source§

#### fn decode(d: &mut D) -> SmallVec<A>

Source§

### impl<D: Decoder, K, V> Decodable<D> for BTreeMap<K, V>
where K: Decodable<D> + PartialEq + Ord, V: Decodable<D>,

Source§

#### fn decode(d: &mut D) -> BTreeMap<K, V>

Source§

### impl<D: Decoder, K, V, S> Decodable<D> for HashMap<K, V, S>
where K: Decodable<D> + Hash + Eq, V: Decodable<D>, S: BuildHasher + Default,

Source§

#### fn decode(d: &mut D) -> HashMap<K, V, S>

Source§

### impl<D: Decoder, K, V, S> Decodable<D> for IndexMap<K, V, S>
where K: Decodable<D> + Hash + Eq, V: Decodable<D>, S: BuildHasher + Default,

Source§

#### fn decode(d: &mut D) -> IndexMap<K, V, S>

Source§

### impl<D: Decoder, T0: Decodable<D>, T1: Decodable<D>, T2: Decodable<D>, T3: Decodable<D>, T4: Decodable<D>, T5: Decodable<D>, T6: Decodable<D>, T7: Decodable<D>, T8: Decodable<D>, T9: Decodable<D>, T10: Decodable<D>, T11: Decodable<D>> Decodable<D> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

Source§

#### fn decode(d: &mut D) -> (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

Source§

### impl<D: Decoder, T1: Decodable<D>, T2: Decodable<D>> Decodable<D> for Result<T1, T2>

Source§

#### fn decode(d: &mut D) -> Result<T1, T2>

Source§

### impl<D: Decoder, T1: Decodable<D>, T2: Decodable<D>, T3: Decodable<D>, T4: Decodable<D>, T5: Decodable<D>, T6: Decodable<D>, T7: Decodable<D>, T8: Decodable<D>, T9: Decodable<D>, T10: Decodable<D>, T11: Decodable<D>> Decodable<D> for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

Source§

#### fn decode(d: &mut D) -> (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

Source§

### impl<D: Decoder, T2: Decodable<D>, T3: Decodable<D>, T4: Decodable<D>, T5: Decodable<D>, T6: Decodable<D>, T7: Decodable<D>, T8: Decodable<D>, T9: Decodable<D>, T10: Decodable<D>, T11: Decodable<D>> Decodable<D> for (T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

Source§

#### fn decode(d: &mut D) -> (T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

Source§

### impl<D: Decoder, T3: Decodable<D>, T4: Decodable<D>, T5: Decodable<D>, T6: Decodable<D>, T7: Decodable<D>, T8: Decodable<D>, T9: Decodable<D>, T10: Decodable<D>, T11: Decodable<D>> Decodable<D> for (T3, T4, T5, T6, T7, T8, T9, T10, T11)

Source§

#### fn decode(d: &mut D) -> (T3, T4, T5, T6, T7, T8, T9, T10, T11)

Source§

### impl<D: Decoder, T4: Decodable<D>, T5: Decodable<D>, T6: Decodable<D>, T7: Decodable<D>, T8: Decodable<D>, T9: Decodable<D>, T10: Decodable<D>, T11: Decodable<D>> Decodable<D> for (T4, T5, T6, T7, T8, T9, T10, T11)

Source§

#### fn decode(d: &mut D) -> (T4, T5, T6, T7, T8, T9, T10, T11)

Source§

### impl<D: Decoder, T5: Decodable<D>, T6: Decodable<D>, T7: Decodable<D>, T8: Decodable<D>, T9: Decodable<D>, T10: Decodable<D>, T11: Decodable<D>> Decodable<D> for (T5, T6, T7, T8, T9, T10, T11)

Source§

#### fn decode(d: &mut D) -> (T5, T6, T7, T8, T9, T10, T11)

Source§

### impl<D: Decoder, T6: Decodable<D>, T7: Decodable<D>, T8: Decodable<D>, T9: Decodable<D>, T10: Decodable<D>, T11: Decodable<D>> Decodable<D> for (T6, T7, T8, T9, T10, T11)

Source§

#### fn decode(d: &mut D) -> (T6, T7, T8, T9, T10, T11)

Source§

### impl<D: Decoder, T7: Decodable<D>, T8: Decodable<D>, T9: Decodable<D>, T10: Decodable<D>, T11: Decodable<D>> Decodable<D> for (T7, T8, T9, T10, T11)

Source§

#### fn decode(d: &mut D) -> (T7, T8, T9, T10, T11)

Source§

### impl<D: Decoder, T8: Decodable<D>, T9: Decodable<D>, T10: Decodable<D>, T11: Decodable<D>> Decodable<D> for (T8, T9, T10, T11)

Source§

#### fn decode(d: &mut D) -> (T8, T9, T10, T11)

Source§

### impl<D: Decoder, T9: Decodable<D>, T10: Decodable<D>, T11: Decodable<D>> Decodable<D> for (T9, T10, T11)

Source§

#### fn decode(d: &mut D) -> (T9, T10, T11)

Source§

### impl<D: Decoder, T10: Decodable<D>, T11: Decodable<D>> Decodable<D> for (T10, T11)

Source§

#### fn decode(d: &mut D) -> (T10, T11)

Source§

### impl<D: Decoder, T11: Decodable<D>> Decodable<D> for (T11,)

Source§

#### fn decode(d: &mut D) -> (T11,)

Source§

### impl<D: Decoder, T> Decodable<D> for BTreeSet<T>
where T: Decodable<D> + PartialEq + Ord,

Source§

#### fn decode(d: &mut D) -> BTreeSet<T>

Source§

### impl<D: Decoder, T> Decodable<D> for PhantomData<T>

Source§

#### fn decode(_: &mut D) -> PhantomData<T>

Source§

### impl<D: Decoder, T, S> Decodable<D> for HashSet<T, S>
where T: Decodable<D> + Hash + Eq, S: BuildHasher + Default,

Source§

#### fn decode(d: &mut D) -> HashSet<T, S>

Source§

### impl<D: Decoder, T, S> Decodable<D> for IndexSet<T, S>
where T: Decodable<D> + Hash + Eq, S: BuildHasher + Default,

Source§

#### fn decode(d: &mut D) -> IndexSet<T, S>

Source§

### impl<D: Decoder, T: Decodable<D> + ToOwned> Decodable<D> for Cow<'static, [T]>
where [T]: ToOwned<Owned = Vec<T>>,

Source§

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

Source§

### impl<D: Decoder, T: Decodable<D> + Copy> Decodable<D> for Cell<T>

Source§

#### fn decode(d: &mut D) -> Cell<T>

Source§

### impl<D: Decoder, T: Decodable<D>> Decodable<D> for Option<T>

Source§

#### fn decode(d: &mut D) -> Option<T>

Source§

### impl<D: Decoder, T: Decodable<D>> Decodable<D> for Box<[T]>

Source§

#### fn decode(d: &mut D) -> Box<[T]>

Source§

### impl<D: Decoder, T: Decodable<D>> Decodable<D> for Box<T>

Source§

#### fn decode(d: &mut D) -> Box<T>

Source§

### impl<D: Decoder, T: Decodable<D>> Decodable<D> for VecDeque<T>

Source§

#### fn decode(d: &mut D) -> VecDeque<T>

Source§

### impl<D: Decoder, T: Decodable<D>> Decodable<D> for Rc<[T]>

Source§

#### fn decode(d: &mut D) -> Rc<[T]>

Source§

### impl<D: Decoder, T: Decodable<D>> Decodable<D> for Rc<T>

Source§

#### fn decode(d: &mut D) -> Rc<T>

Source§

### impl<D: Decoder, T: Decodable<D>> Decodable<D> for Arc<[T]>

Source§

#### fn decode(d: &mut D) -> Arc<[T]>

Source§

### impl<D: Decoder, T: Decodable<D>> Decodable<D> for Arc<T>

Source§

#### fn decode(d: &mut D) -> Arc<T>

Source§

### impl<D: Decoder, T: Decodable<D>> Decodable<D> for Vec<T>

Source§

#### default fn decode(d: &mut D) -> Vec<T>

Source§

### impl<D: Decoder, T: Decodable<D>> Decodable<D> for RefCell<T>

Source§

#### fn decode(d: &mut D) -> RefCell<T>

Source§

### impl<D: Decoder, T: Decodable<D>> Decodable<D> for ThinVec<T>

Source§

#### fn decode(d: &mut D) -> ThinVec<T>

Source§

### impl<D: Decoder, const N: usize> Decodable<D> for [u8; N]

Source§

#### fn decode(d: &mut D) -> [u8; N]

## Implementors§

Source§

### impl<'a> Decodable<MemDecoder<'a>> for IntEncodedWithFixedSize