Decode

Trait Decode 

Source
pub trait Decode<'b>: Sized {
    type Error: Error + 'static;

    // Required method
    fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>;
}
Expand description

A type that can be decoded from CBOR.

Required Associated Types§

Source

type Error: Error + 'static

The error type returned when decoding fails.

Required Methods§

Source

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Decode a value using the given Decoder.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Decode<'_> for bool

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'_>) -> Result<Self, Self::Error>

Source§

impl Decode<'_> for f32

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'_>) -> Result<Self, Self::Error>

Source§

impl Decode<'_> for f64

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'_>) -> Result<f64, Self::Error>

Source§

impl Decode<'_> for i128

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'_>) -> Result<Self, Self::Error>

Source§

impl Decode<'_> for u64

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'_>) -> Result<Self, Self::Error>

Source§

impl Decode<'_> for u128

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'_>) -> Result<Self, Self::Error>

Source§

impl Decode<'_> for AtomicBool

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'_>) -> Result<Self, Self::Error>

Source§

impl Decode<'_> for AtomicU8

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'_>) -> Result<Self, Self::Error>

Source§

impl<'a> Decode<'a> for Box<str>

Available on crate feature alloc only.

Decodes a byte string, supporting both definite-length and indefinite-length encodings.

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'a>) -> Result<Self, Self::Error>

Source§

impl<'a> Decode<'a> for Box<[u8]>

Available on crate feature alloc only.

Decodes a byte string, supporting both definite-length and indefinite-length encodings.

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'a>) -> Result<Self, Self::Error>

Source§

impl<'a> Decode<'a> for String

Available on crate feature alloc only.

Decodes a byte string, supporting both definite-length and indefinite-length encodings.

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'a>) -> Result<Self, Self::Error>

Source§

impl<'a> Decode<'a> for Vec<u8>

Available on crate feature alloc only.

Decodes a byte string, supporting both definite-length and indefinite-length encodings.

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'a>) -> Result<Self, Self::Error>

Source§

impl<'a, 'b> Decode<'b> for &'a str
where 'b: 'a,

Decodes a definite-length string.

If you need to also support indefinite-length byte strings, consider using an allocated type such as String or Box<str>.

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'a, 'b> Decode<'b> for &'a [u8]
where 'b: 'a,

Decodes a definite-length byte string.

If you need to also support indefinite-length byte strings, consider using an allocated type such as Vec<u8> or Box<[u8]>.

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'a, 'b, T> Decode<'b> for Cow<'a, T>
where T: ToOwned + ?Sized + 'a, &'a T: Decode<'b>, T::Owned: Decode<'b>,

Available on crate feature alloc only.
Source§

type Error = <<T as ToOwned>::Owned as Decode<'b>>::Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'a, K, V, const N: usize> Decode<'a> for [(K, V); N]
where K: Decode<'a>, V: Decode<'a>,

Source§

type Error = Error<Error<<K as Decode<'a>>::Error, <V as Decode<'a>>::Error>>

Source§

fn decode(d: &mut Decoder<'a>) -> Result<Self, Self::Error>

Source§

impl<'a, T, const N: usize> Decode<'a> for [T; N]
where T: Decode<'a>,

Source§

type Error = Error<<T as Decode<'a>>::Error>

Source§

fn decode(d: &mut Decoder<'a>) -> Result<Self, Self::Error>

Source§

impl<'a, T: Decode<'a>> Decode<'a> for Option<T>

Source§

type Error = <T as Decode<'a>>::Error

Source§

fn decode(d: &mut Decoder<'a>) -> Result<Self, T::Error>

Source§

impl<'b> Decode<'b> for &'b Path

Available on crate feature std only.

Decodes a definite-length string as a &Path.

If you need to also support indefinite-length byte strings, consider using an allocated type such as PathBuf or Box<Path>.

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Error>

Source§

impl<'b> Decode<'b> for i8

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Error>

Source§

impl<'b> Decode<'b> for i16

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Error>

Source§

impl<'b> Decode<'b> for i32

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Error>

Source§

impl<'b> Decode<'b> for i64

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Error>

Source§

impl<'b> Decode<'b> for isize

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Error>

Source§

impl<'b> Decode<'b> for u16

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Error>

Source§

impl<'b> Decode<'b> for u32

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Error>

Source§

impl<'b> Decode<'b> for usize

Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Error>

Source§

impl<'b> Decode<'b> for Box<Path>

Available on crate feature std only.
Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Error>

Source§

impl<'b> Decode<'b> for NonZero<i8>

Source§

type Error = Error<<i8 as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for NonZero<i16>

Source§

type Error = Error<<i16 as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for NonZero<i32>

Source§

type Error = Error<<i32 as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for NonZero<i64>

Source§

type Error = Error<<i64 as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for NonZero<isize>

Source§

type Error = Error<<isize as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for NonZero<u16>

Source§

type Error = Error<<u16 as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for NonZero<u32>

Source§

type Error = Error<<u32 as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for NonZero<u64>

Source§

type Error = Error<<u64 as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for NonZero<usize>

Source§

type Error = Error<<usize as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for AtomicI8

Source§

type Error = <i8 as Decode<'b>>::Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for AtomicI16

Source§

type Error = <i16 as Decode<'b>>::Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for AtomicI32

Source§

type Error = <i32 as Decode<'b>>::Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for AtomicI64

Source§

type Error = <i64 as Decode<'b>>::Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for AtomicIsize

Source§

type Error = <isize as Decode<'b>>::Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for AtomicU16

Source§

type Error = <u16 as Decode<'b>>::Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for AtomicU32

Source§

type Error = <u32 as Decode<'b>>::Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for AtomicU64

Source§

type Error = <u64 as Decode<'b>>::Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for AtomicUsize

Source§

type Error = <usize as Decode<'b>>::Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b> Decode<'b> for PathBuf

Available on crate feature std only.
Source§

type Error = Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Error>

Source§

impl<'b> Decode<'b> for NonZeroU8

Source§

type Error = Error<Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, K, V> Decode<'b> for BinaryHeap<(K, V)>
where K: Decode<'b> + Ord, V: Decode<'b> + Ord,

Available on crate feature alloc only.
Source§

type Error = Error<Error<<K as Decode<'b>>::Error, <V as Decode<'b>>::Error>>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, K, V> Decode<'b> for BTreeMap<K, V>
where K: Decode<'b> + Eq + Ord, V: Decode<'b>,

Available on crate feature alloc only.
Source§

type Error = Error<Error<<K as Decode<'b>>::Error, <V as Decode<'b>>::Error>>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, K, V> Decode<'b> for BTreeSet<(K, V)>
where K: Decode<'b> + Ord, V: Decode<'b> + Ord,

Available on crate feature alloc only.
Source§

type Error = Error<Error<<K as Decode<'b>>::Error, <V as Decode<'b>>::Error>>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, K, V, S> Decode<'b> for HashMap<K, V, S>
where K: Decode<'b> + Eq + Hash, V: Decode<'b>, S: BuildHasher + Default,

Available on crate feature std only.
Source§

type Error = Error<Error<<K as Decode<'b>>::Error, <V as Decode<'b>>::Error>>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, K, V, S> Decode<'b> for HashSet<(K, V), S>
where K: Decode<'b> + Eq + Hash, V: Decode<'b> + Eq + Hash, S: BuildHasher + Default,

Available on crate feature std only.
Source§

type Error = Error<Error<<K as Decode<'b>>::Error, <V as Decode<'b>>::Error>>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, K: Decode<'b>, V: Decode<'b>> Decode<'b> for LinkedList<(K, V)>

Source§

type Error = Error<Error<<K as Decode<'b>>::Error, <V as Decode<'b>>::Error>>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, K: Decode<'b>, V: Decode<'b>> Decode<'b> for VecDeque<(K, V)>

Source§

type Error = Error<Error<<K as Decode<'b>>::Error, <V as Decode<'b>>::Error>>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, K: Decode<'b>, V: Decode<'b>> Decode<'b> for Vec<(K, V)>

Source§

type Error = Error<Error<<K as Decode<'b>>::Error, <V as Decode<'b>>::Error>>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, T> Decode<'b> for BinaryHeap<T>
where T: Decode<'b> + Ord,

Available on crate feature alloc only.
Source§

type Error = Error<<T as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, T> Decode<'b> for BTreeSet<T>
where T: Decode<'b> + Ord,

Available on crate feature alloc only.
Source§

type Error = Error<<T as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, T, S> Decode<'b> for HashSet<T, S>
where T: Decode<'b> + Eq + Hash, S: BuildHasher + Default,

Available on crate feature std only.
Source§

type Error = Error<<T as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, T: Decode<'b>> Decode<'b> for Box<T>

Available on crate feature alloc only.
Source§

type Error = <T as Decode<'b>>::Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, T::Error>

Source§

impl<'b, T: Decode<'b>> Decode<'b> for LinkedList<T>

Source§

type Error = Error<<T as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, T: Decode<'b>> Decode<'b> for VecDeque<T>

Source§

type Error = Error<<T as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, T: Decode<'b>> Decode<'b> for Vec<T>

Source§

type Error = Error<<T as Decode<'b>>::Error>

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, T: Decode<'b>> Decode<'b> for Cell<T>

Source§

type Error = <T as Decode<'b>>::Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, T: Decode<'b>> Decode<'b> for RefCell<T>

Source§

type Error = <T as Decode<'b>>::Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<'b, T: Decode<'b>> Decode<'b> for Wrapping<T>

Source§

type Error = <T as Decode<'b>>::Error

Source§

fn decode(d: &mut Decoder<'b>) -> Result<Self, Self::Error>

Source§

impl<const N: usize> Decode<'_> for [u8; N]

Decodes a byte string, supporting only definite-length encodings.

Source§

type Error = Error<Infallible>

Source§

fn decode(d: &mut Decoder<'_>) -> Result<Self, Self::Error>

Implementors§

Source§

impl Decode<'_> for Int

Source§

impl Decode<'_> for U8

Source§

impl Decode<'_> for Null

Source§

impl Decode<'_> for Simple

Source§

impl Decode<'_> for Undefined

Source§

impl<'a, T, const N: u64> Decode<'a> for Tagged<T, N>
where T: Decode<'a>,

Source§

type Error = Error<<T as Decode<'a>>::Error>

Source§

impl<'a, T: Decode<'a>> Decode<'a> for Dynamic<T>

Source§

type Error = Error<<T as Decode<'a>>::Error>

Source§

impl<'b> Decode<'b> for Token<'b>