1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! 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);
//!
//! # Ok::<_, Box<dyn core::error::Error>>(())
//! ```
//!
//! [serde]: https://serde.rs/
//! [minicbor-derive]: https://docs.rs/minicbor_derive/
extern crate alloc;
pub use ;
pub use Serializer;
pub use to_vec;