#cbor #serde #no-std #rust

macro no-std serde-indexed

Derivation of Serialize and Deserialize that replaces struct keys with numerical indices

6 releases

0.1.1 Jun 19, 2024
0.1.0 Jan 31, 2021
0.0.4 Mar 27, 2020
0.0.2 Jan 12, 2020

#2298 in Encoding

Download history 222/week @ 2024-07-27 74/week @ 2024-08-03 134/week @ 2024-08-10 41/week @ 2024-08-17 53/week @ 2024-08-24 59/week @ 2024-08-31 47/week @ 2024-09-07 73/week @ 2024-09-14 83/week @ 2024-09-21 198/week @ 2024-09-28 132/week @ 2024-10-05 253/week @ 2024-10-12 430/week @ 2024-10-19 111/week @ 2024-10-26 68/week @ 2024-11-02 133/week @ 2024-11-09

827 downloads per month
Used in 6 crates (3 directly)

Apache-2.0 OR MIT

18KB
305 lines

serde-indexed

crates.io Documentation

Derivation of Serialize and Deserialize that replaces struct keys with numerical indices.

Primary use case is to handle CTAP CBOR messages, in particular support for:

Example

#[derive(Clone, Debug, PartialEq, SerializeIndexed, DeserializeIndexed)]
#[serde_indexed(offset = 1)]
pub struct SomeKeys {
    pub number: i32,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub option: Option<u8>,
    pub bytes: [u8; 7],
}

This was a nice opportunity to learn proc-macros, I roughly followed serde-repr.

To see some generated code, run cargo expand --test basics.

License

serde-indexed is licensed under either of Apache License, Version 2.0 or MIT License at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~230–670KB
~16K SLoC