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§
Provided Methods§
sourcefn is_nil(&self) -> bool
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.