[][src]Crate cbor_data

A library for using CBOR as in-memory representation for working with dynamically shaped data.

For the details on the data format see RFC7049. It is normally meant to be used as a data interchange format that models a superset of the JSON features while employing a more compact binary representation. As such, the data representation is biased towards smaller in-memory size and not towards fastest data access speed.

This library presents a range of tradeoffs when using this data format. You can just use the bits you get from the wire or from a file, without paying any initial overhead but with the possibility of panicking during access and having to allocate when extracting (byte) strings in case indefinite size encoding was used. Or you can validate and canonicalise the bits before using them, removing the possibility of pancis and guaranteeing that indexing into the data will never allocate.

Regarding performance you should keep in mind that arrays and dictionaries are encoded as flat juxtaposition of its elements, meaning that indexing will have to decode items as it skips over them.

CBOR tags are faithfully reported (well, the innermost one, in case multiple are present — the RFC is not perfectly clear here) but not interpreted at this point, meaning that a bignum will come out as a binary string with a tag.

Structs

ArrayBuilder

Builder for an array value.

Cbor

Wrapper around some bytes (referenced or owned) that allows parsing as CBOR value.

CborBuilder

Builder for a single CBOR value.

DictBuilder

Builder for an dict value.

Enums

CborValue

Low-level decoded form of a CBOR item. Use TaggedValue for inspecting values.

Literal

Low-level representation of major type 7 values.

TaggedValue

Representation of a possibly tagged CBOR data item.

Traits

WriteToArray

The actual data writing methods of ArrayBuilder.

WriteToDict

The actual data writing methods of DictBuilder.