pub enum Token<'b> {
}
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
sourceimpl Display for 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 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]
wheren
denotes the number of elements. The followingn
tokens are elements of this array. - A map is displayed as
M[n]
wheren
denotes the number of pairs. The followingn
tokens are entries of this map. - Tags are displayed with
T(t)
wheret
is the tag number. - Simple values are displayed as
simple(n)
wheren
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 aToken::Break
is encountered. All tokens in between belong to the indefinite container.
Token::Null
is displayed asnull
andToken::Undefined
asundefined
.
impl<'b> Copy for Token<'b>
impl<'b> StructuralPartialEq for Token<'b>
Auto Trait Implementations
impl<'b> RefUnwindSafe for Token<'b>
impl<'b> Send for Token<'b>
impl<'b> Sync for Token<'b>
impl<'b> Unpin for Token<'b>
impl<'b> UnwindSafe for Token<'b>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more