Struct cbor_data::Cbor[][src]

pub struct Cbor<'a>(_);
Expand description

Wrapper around a byte slice that allows parsing as CBOR value.

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 CborOwned::canonical constructor. In case the message was encoded for example using CborBuilder it is sufficient to use the trusting constructor.

Implementations

Wrap in Cbor for indexing.

No checks on the integrity are made, indexing methods may panic if encoded lengths are out of bound or when encountering indefinite size (byte) strings. If you want to carefully treat data obtained from unreliable sources, prefer CborOwned::canonical. The results of CborBuilder can also safely be fed to this method.

Copy the underlying bytes to create a fully owned CBOR value.

No checks on the integrity are made, indexing methods may panic if encoded lengths are out of bound or when encountering indefinite size (byte) strings. If you want to carefully treat data obtained from unreliable sources, prefer CborOwned::canonical. The results of CborBuilder can also safely be fed to this method.

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.

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.

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.