6 releases

0.3.2 Sep 30, 2024
0.3.1 Sep 12, 2024
0.2.1 Sep 5, 2024
0.1.0 Sep 3, 2024

#1246 in Encoding

Download history 380/week @ 2024-09-02 189/week @ 2024-09-09 66/week @ 2024-09-16 9/week @ 2024-09-23 168/week @ 2024-09-30 8/week @ 2024-10-07 7/week @ 2024-10-14

199 downloads per month

BlueOak-1.0.0

220KB
5.5K SLoC

minicbor-serde

Integrates minicbor with serde.

Documentation

Documentation is available at https://docs.rs/minicbor_serde/

License

This software is licensed under the Blue Oak Model License Version 1.0.0. If you are interested in contributing to this project, please read the file CONTRIBUTING.md first.


lib.rs:

Support for (de-)serialising CBOR with serde.

In contrast to minicbor-derive, this serde-based implementation makes no attempt to be particularly clever with regards to forward and backward compatibility, nor does it use integers instead of strings for struct field names or enum constructors. If those features are important, consider using minicbor-derive instead.

Example

use serde::{Deserialize, Serialize};

#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
struct S {
    field: bool
}

let s1 = S::default();

let cbor = minicbor_serde::to_vec(&s1)?;
let s2: S = minicbor_serde::from_slice(&cbor)?;

assert_eq!(s1, s2);

let mut buf = Vec::new();
let mut ser = minicbor_serde::Serializer::new(&mut buf);
s1.serialize(&mut ser)?;

let mut de = minicbor_serde::Deserializer::new(&buf);
let s3 = S::deserialize(&mut de)?;

assert_eq!(s1, s3);

Dependencies

~110–400KB