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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Concise Diagnostic Notation (CDN) input helpers and output re-exports.
use Vec;
use DeserializeOwned;
pub use crateError;
pub use crate;
/// Encodes one Concise Diagnostic Notation (CDN) item as CBOR bytes.
///
/// This accepts the formalized diagnostic input syntax from
/// `draft-ietf-cbor-edn-literals`: JSON-compatible values, CBOR byte strings
/// (`'..'`, `h'..'`, `b64'..'`), comments, optional separator commas,
/// embedded CBOR sequence literals (`<<..>>`), tags, simple values, the core
/// encoding indicators (`_i`, `_0` through `_3`, and indefinite arrays or
/// maps with `[_` / `{_`), and the application extensions implemented by this
/// crate. The built-in extensions include `dt`/`DT`, `ip`/`IP`, `b1`/`t1`,
/// `ilbs`/`ilts`, `bytes`, `same`, and `float`; enabling the `cdn` feature
/// also enables the `hash`, `cri`, and `CRI` extensions that require external
/// crates. The default encoding is preferred serialization.
///
/// ```rust
/// let bytes = cbor2::cdn_to_vec(r#"{ /kty/ 1: 4, "kid": h'deadbeef' }"#).unwrap();
/// assert_eq!(cbor2::to_cdn(&bytes[..]).unwrap(), r#"{1: 4, "kid": h'deadbeef'}"#);
/// ```
/// Encodes a CDN sequence as a CBOR sequence.
///
/// Top-level items may be separated by commas or by blank space/comments.
/// This is the same sequence grammar used inside CDN's `<<..>>` embedded
/// CBOR literals, but without wrapping the result as a byte string.
/// Deserializes one CDN item into a serde value.
///
/// Borrowed output fields are not supported by this helper because the CDN
/// text is first encoded into owned CBOR bytes. Use [`cdn_to_vec`] and
/// then [`from_slice`](crate::from_slice) directly when you need control over
/// the encoded bytes.