Trait minicbor::encode::Encode

source ·
pub trait Encode {
    // Required method
    fn encode<W: Write>(
        &self,
        e: &mut Encoder<W>,
    ) -> Result<(), Error<W::Error>>;

    // Provided method
    fn is_nil(&self) -> bool { ... }
}
Expand description

A type that can be encoded to CBOR.

If this type’s CBOR encoding is meant to be decoded by Decode impls derived with minicbor_derive it is advisable to only produce a single CBOR data item. Tagging, maps or arrays can and should be used for multiple values.

Required Methods§

source

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

Encode a value of this type using the given Encoder.

Provided Methods§

source

fn is_nil(&self) -> bool

Is this value of Self a nil value?

This method is primarily used by minicbor-derive.

Some types have a special value to denote the concept of “nothing”, aka nil. An example is the Option type with its None value. This method–if overriden–allows checking if a value is such a special nil value.

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

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Encode for IpAddr

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for SocketAddr

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for bool

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for char

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for f32

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for f64

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for i8

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for i16

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for i32

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for i64

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for isize

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for str

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for u8

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for u16

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for u32

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for u64

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for ()

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for usize

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for String

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for Ipv4Addr

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for Ipv6Addr

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for SocketAddrV4

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for SocketAddrV6

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for AtomicBool

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for AtomicI8

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for AtomicI16

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for AtomicI32

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for AtomicI64

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for AtomicIsize

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for AtomicU8

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for AtomicU16

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for AtomicU32

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for AtomicU64

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for AtomicUsize

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for Duration

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for Path

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for PathBuf

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for SystemTime

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for NonZeroI8

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for NonZeroI16

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for NonZeroI32

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for NonZeroI64

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for NonZeroU8

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for NonZeroU16

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for NonZeroU32

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl Encode for NonZeroU64

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<A: Encode> Encode for (A,)

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<A: Encode, B: Encode> Encode for (A, B)

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<A: Encode, B: Encode, C: Encode> Encode for (A, B, C)

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<A: Encode, B: Encode, C: Encode, D: Encode> Encode for (A, B, C, D)

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<A: Encode, B: Encode, C: Encode, D: Encode, E: Encode> Encode for (A, B, C, D, E)

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<A: Encode, B: Encode, C: Encode, D: Encode, E: Encode, F: Encode> Encode for (A, B, C, D, E, F)

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<A: Encode, B: Encode, C: Encode, D: Encode, E: Encode, F: Encode, G: Encode> Encode for (A, B, C, D, E, F, G)

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

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

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

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

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

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

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

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

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

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

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

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

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

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

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

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

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

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

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<K, V> Encode for BTreeMap<K, V>
where K: Encode + Eq + Ord, V: Encode,

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<K, V, S> Encode for HashMap<K, V, S>
where K: Encode + Eq + Hash, V: Encode, S: BuildHasher,

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T> Encode for PhantomData<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T, S> Encode for HashSet<T, S>
where T: Encode, S: BuildHasher,

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode + Copy> Encode for Cell<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode + ?Sized> Encode for &T

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode + ?Sized> Encode for &mut T

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode + ?Sized> Encode for Box<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for Bound<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for Option<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

fn is_nil(&self) -> bool

source§

impl<T: Encode> Encode for [T; 0]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 1]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 2]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 3]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 4]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 5]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 6]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 7]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 8]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 9]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 10]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 11]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 12]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 13]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 14]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 15]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T; 16]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for [T]

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for BinaryHeap<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for BTreeSet<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for LinkedList<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for VecDeque<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for Vec<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for RefCell<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for Wrapping<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for Range<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for RangeFrom<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for RangeInclusive<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for RangeTo<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode> Encode for RangeToInclusive<T>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

source§

impl<T: Encode, E: Encode> Encode for Result<T, E>

source§

fn encode<W: Write>(&self, e: &mut Encoder<W>) -> Result<(), Error<W::Error>>

Implementors§

source§

impl Encode for ByteSlice

source§

impl Encode for ByteVec

source§

impl Encode for Cbor<'_>

source§

impl<T> Encode for Cow<'_, T>
where T: Encode + ToOwned + ?Sized,

source§

impl<const N: usize> Encode for ByteArray<N>