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.
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().
pub fn index_iter<'b>(
&self,
path: impl IntoIterator<Item = &'b str>
) -> Option<CborValue<'_>>
pub fn index_iter<'b>(
&self,
path: impl IntoIterator<Item = &'b str>
) -> Option<CborValue<'_>>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().
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for CborOwnedimpl UnwindSafe for CborOwnedBlanket Implementations
Mutably borrows from an owned value. Read more