[][src]Enum cbor_diag::DataItem

pub enum DataItem {
    Integer {
        value: u64,
        bitwidth: IntegerWidth,
    },
    Negative {
        value: u64,
        bitwidth: IntegerWidth,
    },
    ByteString(ByteString),
    TextString(TextString),
    IndefiniteByteString(Vec<ByteString>),
    IndefiniteTextString(Vec<TextString>),
    Array {
        data: Vec<DataItem>,
        bitwidth: Option<IntegerWidth>,
    },
    Map {
        data: Vec<(DataItem, DataItem)>,
        bitwidth: Option<IntegerWidth>,
    },
    Tag {
        tag: Tag,
        bitwidth: IntegerWidth,
        value: Box<DataItem>,
    },
    Float {
        value: f64,
        bitwidth: FloatWidth,
    },
    Simple(Simple),
}

A CBOR data item.

See RFC 7049 § 1.2: Data item.

Variants

Integer

An unsigned integer.

See RFC 7049 § 2.1: Major type 0.

Fields of Integer

value: u64

The value of this unsigned integer.

bitwidth: IntegerWidth

The bitwidth used for encoding this integer.

Negative

A negative integer.

See RFC 7049 § 2.1: Major type 0.

Fields of Negative

value: u64

The encoded value of this negative integer, the real value is -1 - value (requires use of i128 for full range support).

bitwidth: IntegerWidth

The bitwidth used for encoding this integer.

ByteString(ByteString)

A string of raw bytes with no direct attached meaning.

See the docs for ByteString for more details.

TextString(TextString)

A UTF-8 encoded text string.

See the docs for TextString for more details.

IndefiniteByteString(Vec<ByteString>)

A series of ByteString chunks encoded as an indefinite length byte string.

See RFC 7049 § 2.2.2.

IndefiniteTextString(Vec<TextString>)

A series of TextString chunks encoded as an indefinite length text string.

See RFC 7049 § 2.2.2.

Array

An array of data items.

See RFC 7049 § 2.1: Major type 4.

Fields of Array

data: Vec<DataItem>

The data items in this array.

bitwidth: Option<IntegerWidth>

The bitwidth used for encoding the array length.

If has the value None then this array is encoded using the indefinite length form, see RFC 7049 § 2.2.1.

Map

A map of pairs of data items.

See RFC 7049 § 2.1: Major type 5.

Fields of Map

data: Vec<(DataItem, DataItem)>

The pairs of data items in this map.

bitwidth: Option<IntegerWidth>

The bitwidth used for encoding the map length.

If has the value None then this map is encoded using the indefinite length form, see RFC 7049 § 2.2.1.

Tag

Semantic tagging of another data item.

See the docs for Tag for more details.

Fields of Tag

tag: Tag

The semantic tag to be applied to value.

bitwidth: IntegerWidth

The bitwidth used to encode the semantic tag.

value: Box<DataItem>

The data item which has the semantic tag applied to it.

Float

A floating point value.

See RFC 7049 § 2.3.

Fields of Float

value: f64

The floating point value.

bitwidth: FloatWidth

The bitwidth used for encoding the value.

Simple(Simple)

A "simple value" data item.

See the docs for Simple for more details.

Implementations

impl DataItem[src]

pub fn to_bytes(&self) -> Vec<u8>[src]

impl DataItem[src]

pub fn to_diag(&self) -> String[src]

pub fn to_diag_pretty(&self) -> String[src]

impl DataItem[src]

pub fn to_hex(&self) -> String[src]

Trait Implementations

impl Clone for DataItem[src]

impl Debug for DataItem[src]

impl PartialEq<DataItem> for DataItem[src]

impl StructuralPartialEq for DataItem[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.