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 |
#1289 in Encoding
Used in bie
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
~100–395KB