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.
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<'a>>
pub fn index_iter<'b>(
&self,
path: impl IntoIterator<Item = &'b str>
) -> Option<CborValue<'a>>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<'a> RefUnwindSafe for Cbor<'a>impl<'a> UnwindSafe for Cbor<'a>