Enum ciborium_ll::Header

source ·
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§

source§

impl Clone for Header

source§

fn clone(&self) -> Header

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Header

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Header

source§

fn eq(&self, other: &Header) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Header

source§

impl StructuralPartialEq for Header

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.