cbor

Members

Classes

CborException
class CborException

Thrown in a case of decoding error.

Functions

decodeCbor
CborValue decodeCbor(R input)

Decodes single value and returns it as CborValue tagged union type. Throws CborException if data is not well-formed. Note, that ubyte[] and string types are slices of input range if ubyte[] was provided. Will modify input range, popping all the bytes of the first item.

decodeCborSingle
T decodeCborSingle(R input)

Decodes single cbor value and tries to convert it to requested type. If types doesn't match CborException is thrown. Note, that ubyte[] and string types are slices of input range if ubyte[] was provided. Will modify input range, popping all the elements of T.

decodeCborSingleDup
T decodeCborSingleDup(R input)

Decodes single cbor value and tries to convert it to requested type. If types doesn't match CborException is thrown. Note, that this version will dup all arrays for you. Will modify input range, popping all the elements of T.

encodeCbor
size_t encodeCbor(R sink, E value)

Encodes value E into output range sink. Returns number of bytes written to sink.

encodeCborAggregate
size_t encodeCborAggregate(R sink, A aggregate)

Encodes classes and structs. If withFieldName is yes, than value is encoded as map. If withFieldName is no, then value is encoded as an array.

encodeCborArray
size_t encodeCborArray(R sink, E value)

Encodes array of any items or a tuple as cbor array.

encodeCborArray
size_t encodeCborArray(R sink, A aggregate)

Encodes structs and classes as cbor array.

encodeCborArrayHead
size_t encodeCborArrayHead(R sink, ulong arrayLength)

Encode array head with arrayLength elements. arrayLength items must follow.

encodeCborBool
size_t encodeCborBool(R sink, E value)

Encodes boolean.

encodeCborFloat
size_t encodeCborFloat(R sink, E value)

Encodes floating.

encodeCborInt
size_t encodeCborInt(R sink, E value)

Encodes integer.

encodeCborMap
size_t encodeCborMap(R sink, E value)

Encodes asociative array as cbor map.

encodeCborMap
size_t encodeCborMap(R sink, A aggregate)

Encodes structs and classes as cbor map. Note, that decoding of structs and classes from maps is not supported (yet).

encodeCborMapHead
size_t encodeCborMapHead(R sink, ulong mapLength)

Encode map head with mapLength elements. mapLength pairs of items must follow. Keys first, then values.

encodeCborNull
size_t encodeCborNull(R sink, E value)

Encodes null.

encodeCborRaw
size_t encodeCborRaw(R sink, E value)

Encodes range of ubytes.

encodeCborString
size_t encodeCborString(R sink, E value)

Encodes string.

Structs

CborValue
struct CborValue

Tagged union for CBOR items.

Templates

numEncodableMembers
template numEncodableMembers(alias T)

Returns a number of aggregate members that will be encoded by cbor-d.

Meta

Standards

Conforms to RFC 7049.

Authors

Andrey Penechko.

Some code is based on msgpack-d by Masahiro Nakagawa.

Concise Binary Object Representation (CBOR) for D lang.

The Concise Binary Object Representation (CBOR) is a data format whose design goals include the possibility of extremely small code size, fairly small message size, and extensibility without the need for version negotiation. These design goals make it different from earlier binary serializations such as ASN.1 and MessagePack.