pub enum Token<'b> {
Show 25 variants Bool(bool), U8(u8), U16(u16), U32(u32), U64(u64), I8(i8), I16(i16), I32(i32), I64(i64), F16(f32), F32(f32), F64(f64), Bytes(&'b [u8]), String(&'b str), Array(u64), Map(u64), Tag(Tag), Simple(u8), Break, Null, Undefined, BeginBytes, BeginString, BeginArray, BeginMap,
}
Expand description

Representation of possible CBOR tokens.

Requires feature "half".

Variants

Bool(bool)

U8(u8)

U16(u16)

U32(u32)

U64(u64)

I8(i8)

I16(i16)

I32(i32)

I64(i64)

F16(f32)

F32(f32)

F64(f64)

Bytes(&'b [u8])

String(&'b str)

Array(u64)

Map(u64)

Tag(Tag)

Simple(u8)

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Pretty print a token.

Since we only show a single token we can not use diagnostic notation as in the Display impl of Tokenizer. 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 h and hex-encoded, e.g. h'01 02 ef'.
  • An array is displayed as A[n] where n denotes the number of elements. The following n tokens are elements of this array.
  • A map is displayed as M[n] where n denotes the number of pairs. The following n tokens are entries of this map.
  • Tags are displayed with T(t) where t is the tag number.
  • Simple values are displayed as simple(n) where n denotes 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 a Token::Break is encountered. All tokens in between belong to the indefinite container.
  • Token::Null is displayed as null and Token::Undefined as undefined.

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.