Skip to main content

Cbor

Derive Macro Cbor 

Source
#[derive(Cbor)]
{
    // Attributes available to this derive:
    #[cbor]
    #[serde]
}
Expand description

Derives serde::Serialize and serde::Deserialize with CBOR protocol details: integer map keys (#[cbor(key = <integer>)] on fields), field-order array structs (#[cbor(array)] on the container) and a CBOR tag (#[cbor(tag = <integer>)] on the container). The tag is written on encode and transparent on decode, so input is accepted with or without it. The declared details are also exposed through an implementation of the cbor2::Cbor trait, so the generated code requires the cbor2 crate under that name.

Do not also derive serde’s Serialize/Deserialize: this macro generates both impls (the implementations would conflict).