Trait minicbor::encode::Encode[][src]

pub trait Encode {
    fn encode<W: Write>(
        &self,
        e: &mut Encoder<W>
    ) -> Result<(), Error<W::Error>>; 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

Encode a value of this type using the given Encoder.

Provided methods

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.

Implementations on Foreign Types

Implementors