pub enum Header {
Positive(u64),
Negative(u64),
Float(f64),
Simple(u8),
Tag(u64),
Break,
Bytes(Option<usize>),
Text(Option<usize>),
Array(Option<usize>),
Map(Option<usize>),
}
Expand description
A semantic representation of a CBOR item header
This structure represents the valid values of a CBOR item header and is
used extensively when serializing or deserializing CBOR items. Note well
that this structure DOES NOT represent the body (i.e. suffix) of the
CBOR item. You must parse the body yourself based on the contents of the
Header
. However, utility functions are provided for this (see:
Decoder::bytes()
and Decoder::text()
).
Variants§
Positive(u64)
A positive integer
Negative(u64)
A negative integer
Note well that this value has all bits inverted from a normal signed
integer. For example, to convert the u64
to a i128
you would do
this: neg as i128 ^ !0
.
Float(f64)
A floating point value
Simple(u8)
A “simple” value
Tag(u64)
A tag
Break
The “break” value
This value is used to terminate indefinite length arrays and maps, as well as segmented byte or text items.
Bytes(Option<usize>)
A bytes item
The value contained in this variant indicates the length of the bytes
which follow or, if None
, segmented bytes input.
A best practice is to call Decoder::bytes()
immediately after
first pulling a bytes item header since this utility function
encapsulates all the logic needed to handle segmentation.
Text(Option<usize>)
A text item
The value contained in this variant indicates the length of the text
which follows (in bytes) or, if None
, segmented text input.
A best practice is to call Decoder::text()
immediately after
first pulling a text item header since this utility function
encapsulates all the logic needed to handle segmentation.
Array(Option<usize>)
An array item
The value contained in this variant indicates the length of the array
which follows (in items) or, if None
, an indefinite length array
terminated by a “break” value.
Map(Option<usize>)
An map item
The value contained in this variant indicates the length of the map
which follows (in item pairs) or, if None
, an indefinite length map
terminated by a “break” value.
Trait Implementations§
impl Copy for Header
impl StructuralPartialEq for Header
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnwindSafe for Header
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes
Size for each variant:
Positive
: 15 bytesNegative
: 15 bytesFloat
: 15 bytesSimple
: 1 byteTag
: 15 bytesBreak
: 0 bytesBytes
: 11 bytesText
: 11 bytesArray
: 11 bytesMap
: 11 bytes