Trait minicbor::decode::Decode

source ·
pub trait Decode<'b>: Sized {
    // Required method
    fn decode(d: &mut Decoder<'b>) -> 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>) -> Result<Self, Error>

Decode a value using the given Decoder.

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> Decode<'b> for &'a str

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

fn nil() -> Option<Self>

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

Implementors§

source§

impl Decode<'_> for ByteVec

source§

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

source§

impl<'b> Decode<'b> for Cbor<'b>

source§

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

source§

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