[][src]Struct cbor_data::CborOwned

pub struct CborOwned(_);

Implementations

impl CborOwned[src]

pub fn trusting(bytes: impl Into<Vec<u8>>) -> Self[src]

Copy the bytes and wrap for indexing.

No checks on the integrity are made, indexing methods may panic if encoded lengths are out of bound. If you want to carefully treat data obtained from unreliable sources, prefer canonical().

pub fn canonical(
    bytes: impl AsRef<[u8]>,
    scratch_space: Option<&mut Vec<u8>>
) -> Option<Self>
[src]

Copy the bytes while checking for integrity and replacing indefinite (byte) strings with definite ones.

This constructor will go through and decode the whole provided CBOR bytes and write them into a vector, thereby

  • retaining only innermost tags
  • writing arrays and dicts using indefinite size format
  • writing numbers in their smallest form

The used vector can be provided (to reuse previously allocated memory) or newly created. In the former case all contents of the provided argument will be cleared.

pub fn borrow(&self) -> Cbor<'_>[src]

Borrow the underlying bytes for Cbor interpretation.

pub fn as_slice(&self) -> &[u8][src]

A view onto the underlying bytes.

pub fn value(&self) -> Option<CborValue<'_>>[src]

Extract the single value represented by this piece of CBOR.

pub fn index(&self, path: &str) -> Option<CborValue<'_>>[src]

Extract a value by indexing into arrays and dicts, with path elements separated by dot.

The empty string will yield the same as calling value(). If path elements may contain . then use index_iter().

pub fn index_iter<'b>(
    &self,
    path: impl IntoIterator<Item = &'b str>
) -> Option<CborValue<'_>>
[src]

Extract a value by indexing into arrays and dicts, with path elements yielded by an iterator.

The empty iterator will yield the same as calling value().

Trait Implementations

impl AsRef<[u8]> for CborOwned[src]

impl Clone for CborOwned[src]

impl Debug for CborOwned[src]

impl PartialEq<CborOwned> for CborOwned[src]

impl StructuralPartialEq for CborOwned[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.