Struct cbor_data::CborValue[][src]

pub struct CborValue<'a> {
    pub tags: Tags<'a>,
    pub kind: ValueKind<'a>,
    pub bytes: &'a [u8],
}

Representation of a possibly tagged CBOR data item.

Fields

tags: Tags<'a>kind: ValueKind<'a>bytes: &'a [u8]

Implementations

impl<'a> CborValue<'a>[src]

pub fn decoded(&self) -> Option<Self>[src]

Strip off wrappers of CBOR item encoding: sees through byte strings with TAG_CBOR_ITEM.

pub fn tags(&self) -> Tags<'a>

Notable traits for Tags<'a>

impl<'a> Iterator for Tags<'a> type Item = u64;
[src]

Get value all tags, from the outermost to the innermost

pub fn as_bool(&self) -> Option<bool>[src]

pub fn as_u64(&self) -> Option<u64>[src]

Try to interpret this value as a 64bit unsigned integer.

Currently does not check floats or big integers.

pub fn as_i64(&self) -> Option<i64>[src]

Try to interpret this value as a signed integer.

Currently does not check floats or big integers.

pub fn as_i32(&self) -> Option<i32>[src]

Try to interpret this value as a signed integer.

Currently does not check floats or big integers.

pub fn as_f64(&self) -> Option<f64>[src]

Try to interpret this value as a floating-point number.

TODO: add proper representations for the big number types supported by CBOR

pub fn as_bytes(&self) -> Option<Cow<'a, [u8]>>[src]

Try to interpret this value as byte string.

This returns a Cow because it may need to allocate a vector when decoding base64 strings.

pub fn as_str(&self) -> Option<&'a str>[src]

Try to interpret this value as string.

Returns None if the type is not a (byte) string or the bytes are not valid UTF-8. base64 encoded strings (TAG_BASE64 or TAG_BASE64URL) are not decoded but returned as they are (even when their binary decoded form is valid UTF-8).

pub fn as_object(&self) -> Option<CborObject<'a>>[src]

Lift a representation from this CBOR item that turns arrays into vectors and dicts into BTreeMaps.

This method is mostly useful for diagnostics and tests.

Trait Implementations

impl<'a> Clone for CborValue<'a>[src]

impl<'a> Debug for CborValue<'a>[src]

impl<'a> Display for CborValue<'a>[src]

impl<'a> PartialEq<CborValue<'_>> for CborValue<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for CborValue<'a>

impl<'a> Send for CborValue<'a>

impl<'a> Sync for CborValue<'a>

impl<'a> Unpin for CborValue<'a>

impl<'a> UnwindSafe for CborValue<'a>

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> ToString for T where
    T: Display + ?Sized
[src]

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.