Trait minicbor::decode::Decode

source ·
pub trait Decode<'b, C>: Sized {
    // Required method
    fn decode(d: &mut Decoder<'b>, ctx: &mut C) -> Result<Self, Error>;

    // Provided method
    fn nil() -> Option<Self> { ... }
}
Expand description

A type that can be decoded from CBOR.

Required Methods§

source

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

Decode a value using the given Decoder.

In addition to the decoder a user provided decoding context is given as another parameter. Most implementations of this trait do not need a decoding context and should be completely generic in the context type. In cases where a context is needed and the Decode impl type is meant to be combined with other types that require a different context type, it is preferrable to constrain the context type variable C with a trait bound instead of fixing the type.

Provided Methods§

source

fn nil() -> Option<Self>

If possible, return a nil value of Self.

This method is primarily used by minicbor-derive and allows creating a special value denoting the absence of a “real” value if no CBOR value is present. The canonical example of a type where this is sensible is the Option type, whose Decode::nil method would return Some(None).

With the exception of Option<_> all types T are considered mandatory by default, i.e. T::nil() returns None. Missing values of T therefore cause decoding errors in derived Decode implementations.

NB: A type implementing Decode with an overriden Decode::nil method should also override Encode::is_nil if it implements Encode at all.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

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

source§

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

source§

impl<'b, C> Decode<'b, C> for bool

source§

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

source§

impl<'b, C> Decode<'b, C> for char

source§

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

source§

impl<'b, C> Decode<'b, C> for f32

source§

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

source§

impl<'b, C> Decode<'b, C> for f64

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl<'b, C> Decode<'b, C> for u8

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl<'b, C> Decode<'b, C> for u64

source§

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

source§

impl<'b, C> Decode<'b, C> for ()

source§

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

source§

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

source§

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

source§

impl<'b, C> Decode<'b, C> for AtomicBool

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl<'b, C> Decode<'b, C> for AtomicU8

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl<'b, C> Decode<'b, C> for Duration

source§

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

source§

impl<'b, C> Decode<'b, C> for NonZeroI8

source§

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

source§

impl<'b, C> Decode<'b, C> for NonZeroI16

source§

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

source§

impl<'b, C> Decode<'b, C> for NonZeroI32

source§

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

source§

impl<'b, C> Decode<'b, C> for NonZeroI64

source§

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

source§

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

source§

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

source§

impl<'b, C> Decode<'b, C> for NonZeroU16

source§

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

source§

impl<'b, C> Decode<'b, C> for NonZeroU32

source§

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

source§

impl<'b, C> Decode<'b, C> for NonZeroU64

source§

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

source§

impl<'b, C, T> Decode<'b, C> for PhantomData<T>

source§

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

source§

impl<'b, C, T, E> Decode<'b, C> for Result<T, E>
where T: Decode<'b, C>, E: Decode<'b, C>,

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 0]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 1]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 2]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 3]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 4]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 5]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 6]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 7]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 8]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 9]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 10]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 11]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 12]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 13]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 14]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 15]

source§

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

source§

impl<'b, C, T: Decode<'b, C> + Default> Decode<'b, C> for [T; 16]

source§

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

source§

impl<'b, C, T: Decode<'b, C>> Decode<'b, C> for Bound<T>

source§

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

source§

impl<'b, C, T: Decode<'b, C>> Decode<'b, C> for Option<T>

source§

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

source§

fn nil() -> Option<Self>

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl<'b, C, T: Decode<'b, C>> Decode<'b, C> for Range<T>

source§

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

source§

impl<'b, C, T: Decode<'b, C>> Decode<'b, C> for RangeFrom<T>

source§

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

source§

impl<'b, C, T: Decode<'b, C>> Decode<'b, C> for RangeInclusive<T>

source§

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

source§

impl<'b, C, T: Decode<'b, C>> Decode<'b, C> for RangeTo<T>

source§

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

source§

impl<'b, C, T: Decode<'b, C>> Decode<'b, C> for RangeToInclusive<T>

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>> Decode<'b, Ctx> for (A,)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>, C: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B, C)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>, C: Decode<'b, Ctx>, D: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B, C, D)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>, C: Decode<'b, Ctx>, D: Decode<'b, Ctx>, E: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B, C, D, E)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>, C: Decode<'b, Ctx>, D: Decode<'b, Ctx>, E: Decode<'b, Ctx>, F: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B, C, D, E, F)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>, C: Decode<'b, Ctx>, D: Decode<'b, Ctx>, E: Decode<'b, Ctx>, F: Decode<'b, Ctx>, G: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B, C, D, E, F, G)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>, C: Decode<'b, Ctx>, D: Decode<'b, Ctx>, E: Decode<'b, Ctx>, F: Decode<'b, Ctx>, G: Decode<'b, Ctx>, H: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B, C, D, E, F, G, H)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>, C: Decode<'b, Ctx>, D: Decode<'b, Ctx>, E: Decode<'b, Ctx>, F: Decode<'b, Ctx>, G: Decode<'b, Ctx>, H: Decode<'b, Ctx>, I: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B, C, D, E, F, G, H, I)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>, C: Decode<'b, Ctx>, D: Decode<'b, Ctx>, E: Decode<'b, Ctx>, F: Decode<'b, Ctx>, G: Decode<'b, Ctx>, H: Decode<'b, Ctx>, I: Decode<'b, Ctx>, J: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B, C, D, E, F, G, H, I, J)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>, C: Decode<'b, Ctx>, D: Decode<'b, Ctx>, E: Decode<'b, Ctx>, F: Decode<'b, Ctx>, G: Decode<'b, Ctx>, H: Decode<'b, Ctx>, I: Decode<'b, Ctx>, J: Decode<'b, Ctx>, K: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B, C, D, E, F, G, H, I, J, K)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>, C: Decode<'b, Ctx>, D: Decode<'b, Ctx>, E: Decode<'b, Ctx>, F: Decode<'b, Ctx>, G: Decode<'b, Ctx>, H: Decode<'b, Ctx>, I: Decode<'b, Ctx>, J: Decode<'b, Ctx>, K: Decode<'b, Ctx>, L: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B, C, D, E, F, G, H, I, J, K, L)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>, C: Decode<'b, Ctx>, D: Decode<'b, Ctx>, E: Decode<'b, Ctx>, F: Decode<'b, Ctx>, G: Decode<'b, Ctx>, H: Decode<'b, Ctx>, I: Decode<'b, Ctx>, J: Decode<'b, Ctx>, K: Decode<'b, Ctx>, L: Decode<'b, Ctx>, M: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B, C, D, E, F, G, H, I, J, K, L, M)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>, C: Decode<'b, Ctx>, D: Decode<'b, Ctx>, E: Decode<'b, Ctx>, F: Decode<'b, Ctx>, G: Decode<'b, Ctx>, H: Decode<'b, Ctx>, I: Decode<'b, Ctx>, J: Decode<'b, Ctx>, K: Decode<'b, Ctx>, L: Decode<'b, Ctx>, M: Decode<'b, Ctx>, N: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B, C, D, E, F, G, H, I, J, K, L, M, N)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>, C: Decode<'b, Ctx>, D: Decode<'b, Ctx>, E: Decode<'b, Ctx>, F: Decode<'b, Ctx>, G: Decode<'b, Ctx>, H: Decode<'b, Ctx>, I: Decode<'b, Ctx>, J: Decode<'b, Ctx>, K: Decode<'b, Ctx>, L: Decode<'b, Ctx>, M: Decode<'b, Ctx>, N: Decode<'b, Ctx>, O: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)

source§

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

source§

impl<'b, Ctx, A: Decode<'b, Ctx>, B: Decode<'b, Ctx>, C: Decode<'b, Ctx>, D: Decode<'b, Ctx>, E: Decode<'b, Ctx>, F: Decode<'b, Ctx>, G: Decode<'b, Ctx>, H: Decode<'b, Ctx>, I: Decode<'b, Ctx>, J: Decode<'b, Ctx>, K: Decode<'b, Ctx>, L: Decode<'b, Ctx>, M: Decode<'b, Ctx>, N: Decode<'b, Ctx>, O: Decode<'b, Ctx>, P: Decode<'b, Ctx>> Decode<'b, Ctx> for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)

source§

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

Implementors§

source§

impl<'a, 'b: 'a, C> Decode<'b, C> for &'a ByteSlice

source§

impl<'b, C> Decode<'b, C> for Int

source§

impl<'b, C, const N: usize> Decode<'b, C> for ByteArray<N>