As defined in RFC 7049, a CBOR object is an octet sequence encoding a series of core events that correspond to a simple grammar describing the composition of structured data.
This module provides a safe interface for constructing valid CBOR events used by the encoder in
bor_encode
and the decoder in
bor_decode
.
Types
type signal = [
| `Break
| `Octets
| `Text
| `Array
| `Map
]
The type of indefinite-length sequencing signals.
type sign = [
| `Positive
| `Negative
]
The type of integer sign.
type ieee754_precision = [
| `Half
| `Single
| `Double
]
The type of IEEE-754 floating point number precision.
type minor = private
| Minorof int64
The private type of CBOR minor codepoints. This is conceptually an unsigned 64-bit integer, encapsulated here in a private data constructor because the OCaml int64 type is a signed integer.
Use int_to_minor n to make a CBOR minor codepoint of value n. Raises Invalid_argument if n is negative.
val int64_to_minor : ?unsigned:unit ->int64 ->minor
Use int64_to_minor n to make a CBOR minor codepoint of value n. Raises Invalid_argument if n is negative unless the ~unsigned:() optional flag is provided to explicitly signal that n is to be regarded as unsigned.
Use minor_to_intopt minor to extract the positive integer corresponding to minor. Returns None if the codepoint cannot be represented by the positive range of values of the OCaml integer type.
Use float n to make an IEEE 754 floating point number event with n. If ~precision is not used, then the most precise form required to represent n without loss is selected.
Use octets s to make a definite length octet sequence event comprising the octets in s. To make an indefinite length octet sequence event, use the signal `Octets constructor.
Use text s to make a definite length Unicode text sequence event comprising the UTF-8 encoded octets in s. If the octets in s do not comprise a valid UTF-8 encoding, then Cf_decode.Invalid is raised with the position of the invalid octet in s. To make an indefinite length Unicode text event, use the signal `Text constructor.
Use array minor to make an event signaling the start of a definite length array with the length indicated by minor. To make an indefinite length array event, use the signal `Array constructor.
Use map minor to make an event signaling the start of a definite length map with the length indicated by minor. To make an indefinite length map event, use the signal `Map constructor.