cbor

Members

Enums

CborTokenType
enum CborTokenType
ignore
enum ignore

Variables marked with this attribute wont be (de)serialized.

Functions

decodeCborSingle
T decodeCborSingle(auto ref R input)

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

decodeCborSingleDup
T decodeCborSingleDup(auto ref R input)

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

encodeCbor
size_t encodeCbor(auto ref R sink, auto ref const E value)

Encodes value E into output range sink. Returns number of bytes written to sink. If flatten flag is yes then static arrays and structs will be encoded in place without headers.

encodeCborAggregate
size_t encodeCborAggregate(auto ref R sink, auto ref 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. If flatten flag is yes then static arrays and structs will be encoded in place without headers.

encodeCborArray
size_t encodeCborArray(auto ref R sink, E value)

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

encodeCborArray
size_t encodeCborArray(auto ref R sink, A aggregate)

Encodes structs and classes as cbor array.

encodeCborBool
size_t encodeCborBool(auto ref R sink, E value)

Encodes boolean.

encodeCborBreak
size_t encodeCborBreak(auto ref R sink)

Encodes break. Use after all items of indefinite-length sequence were encoded.

encodeCborBytes
size_t encodeCborBytes(auto ref R sink, E value)

Encodes range of ubytes.

encodeCborBytesItems
size_t encodeCborBytesItems(auto ref R sink, D bytes)

Writes range of ubyte to the sink. Needs to go after a call to encodeCborBytesHeader. The length of supplied range must be equal to one provided to encodeCborBytesHeader.

encodeCborFloat
size_t encodeCborFloat(auto ref R sink, E value)

Encodes floating.

encodeCborInt
size_t encodeCborInt(auto ref R sink, E value)

Encodes integer.

encodeCborMap
size_t encodeCborMap(auto ref R sink, E value)

Encodes asociative array as cbor map.

encodeCborMap
size_t encodeCborMap(auto ref R sink, A aggregate)

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

encodeCborNull
size_t encodeCborNull(auto ref R sink)

Encodes null.

encodeCborSimple
size_t encodeCborSimple(auto ref R sink, ubyte simple)

Encodes simple. Simple data type is essentially a number that has special meaning. Value must lie in range [0..23] or [32..255].

encodeCborString
size_t encodeCborString(auto ref R sink, E value)

Encodes string.

encodeCborTag
size_t encodeCborTag(auto ref R sink, ulong value)
encodeCborUndefined
size_t encodeCborUndefined(auto ref R sink)

Encodes undefined.

printCborStream
void printCborStream(auto ref R input, ulong numItems = ulong.max)
void printCborStream(auto ref R input, auto ref Sink sink, ulong numItems = ulong.max, string indent = "")

Outputs textual representation of cbor stream into sink or stdout if not provided.

Structs

CborToken
struct CborToken

Variables

numEncodableMembers
enum size_t numEncodableMembers(A);

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

Meta

Authors

Andrey Penechko.

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.

Standards

Conforms to RFC 7049.