ciborium_ll

Enum 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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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§

§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.

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 bytes
  • Negative: 15 bytes
  • Float: 15 bytes
  • Simple: 1 byte
  • Tag: 15 bytes
  • Break: 0 bytes
  • Bytes: 11 bytes
  • Text: 11 bytes
  • Array: 11 bytes
  • Map: 11 bytes