Expand description
Procedural macros for darkbio-crypto.
Provides the Cbor derive macro for structs that generates both Encode
and Decode implementations.
§Struct encoding modes
By default, structs encode as CBOR maps with integer keys specified via
#[cbor(key = N)]. Use #[cbor(array)] to encode as a CBOR array instead.
§Examples
Map encoding (default):
ⓘ
#[derive(Cbor)]
struct Data {
#[cbor(key = 1)]
name: String,
#[cbor(key = -1)]
value: u64,
}
// Encodes as: {1: name, -1: value} (sorted by bytewise key encoding)Array encoding:
ⓘ
#[derive(Cbor)]
#[cbor(array)]
struct Point {
x: u64,
y: u64,
}
// Encodes as: [x, y]Derive Macros§
- Cbor
- Derives the CBOR encoder and decoder for structs tagged with #[derive(Cbor)] and internally fields tagged with #[cbor(…)].