pub enum Token<'b> {
}Expand description
Representation of possible CBOR tokens.
Variants§
Bool(bool)
Int(Int)
Float(f64)
Bytes(&'b [u8])
String(&'b str)
Array(usize)
Map(usize)
Tag(u64)
Simple(Simple)
Break
Null
Undefined
BeginBytes
Start of indefinite byte string.
BeginString
Start of indefinite text string.
BeginArray
Start of indefinite array.
BeginMap
Start of indefinite map.
Trait Implementations§
Source§impl Display for Token<'_>
Pretty print a token.
impl Display for Token<'_>
Pretty print a token.
Since we only show a single token we can not use diagnostic notation
as in the Display impl of Decoder. Instead, the following
syntax is used:
-
Numeric values and booleans are displayed as in Rust. Floats are always shown in scientific notation.
-
Text strings are displayed in double quotes.
-
Byte strings are displayed in single quotes prefixed with
hand hex-encoded, e.g.h'01 02 ef'. -
An array is displayed as
A[n]wherendenotes the number of elements. The followingntokens are elements of this array. -
A map is displayed as
M[n]wherendenotes the number of pairs. The followingntokens are entries of this map. -
Tags are displayed with
T(t)wheretis the tag number. -
Simple values are displayed as
simple(n)wherendenotes the numeric value. -
Indefinite items start with:
?B[for byte strings,?S[for text strings,?A[for arrays,?M[for maps,
and end with
]when aToken::Breakis encountered. All tokens in between belong to the indefinite container. -
Token::Nullis displayed asnullandToken::Undefinedasundefined.