Struct cbor_data::CborOwned[][src]

pub struct CborOwned(_);
Expand description

Wrapper around a vector of bytes, for parsing as CBOR.

For details on the format see RFC 7049.

When interpreting CBOR messages from the outside (e.g. from the network) it is advisable to ingest those using the canonical constructor. In case the message was encoded for example using CborBuilder it is sufficient to use the trusting constructor.

Canonicalisation rqeuires an intermediary data buffer, which can be supplied (and reused) by the caller to save on allocations.

Implementations

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().

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

For more configuration options like reusing a scratch space or preferring definite size encoding see CborBuilder.

Borrow the underlying bytes for Cbor interpretation.

A view onto the underlying bytes.

Extract the single value represented by this piece of CBOR.

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

Returns None if an index doesn’t exist or the indexed object is neither an array nor a dict. When the object under consideration is an array, the next path element must represent an integer number.

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

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

Returns None if an index doesn’t exist or the indexed object is neither an array nor a dict. When the object under consideration is an array, the next path element must represent an integer number.

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

Visit the interesting parts of this CBOR item as guided by the given Visitor.

Returns false if the visit was not even begun due to invalid or non-canonical CBOR.

Trait Implementations

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.