Skip to main content

cbor_core/
format.rs

1/// Format for CBOR decoding or encoding.
2///
3/// Selected on [`DecodeOptions`](crate::DecodeOptions) to choose how
4/// input bytes are interpreted. All three formats decode to the same
5/// [`Value`](crate::Value) type.
6///
7/// | Variant | Description |
8/// |---|---|
9/// | [`Binary`](Self::Binary) | Standard CBOR binary encoding (RFC 8949). |
10/// | [`Hex`](Self::Hex) | Hex-encoded CBOR binary: each CBOR byte as two ASCII hex digits. |
11/// | [`Diagnostic`](Self::Diagnostic) | CBOR diagnostic notation (Section 8 of RFC 8949, Section 2.3.6 of CBOR::Core). |
12#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
13pub enum Format {
14    /// Standard CBOR binary encoding.
15    #[default]
16    Binary,
17    /// Hex-encoded CBOR binary. Each CBOR byte is represented as two ASCII
18    /// hex digits (upper or lower case).
19    Hex,
20    /// CBOR diagnostic notation (human-readable text).
21    Diagnostic,
22}