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<'a, 'b: 'a, C> Decode<'b, C> for &'a CStr

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

fn decode(d: &mut Decoder<'b>, ctx: &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 Box<str>

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

fn decode(d: &mut Decoder<'b>, ctx: &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 AtomicI64

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 AtomicU64

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 PathBuf

source§

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

source§

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

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, K, V> Decode<'b, C> for BTreeMap<K, V>
where K: Decode<'b, C> + Eq + Ord, V: Decode<'b, C>,

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

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, S> Decode<'b, C> for HashSet<T, S>
where T: Decode<'b, C> + Eq + Hash, S: BuildHasher + Default,

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 Box<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 LinkedList<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 VecDeque<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 Vec<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 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, C, T: Decode<'b, C>, const N: usize> Decode<'b, C> for [T; N]

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 Token<'b>

source§

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

source§

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

source§

impl<'b, C, const N: u64, T: Decode<'b, C>> Decode<'b, C> for Tagged<N, T>

source§

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

source§

impl<C> Decode<'_, C> for ByteVec