package orsetto
Install
Dune Dependency
Authors
Maintainers
Sources
sha512=9b654edb663ae697563f150824047052f3b1bf760398f24bce6350553f031f73c46b6337239a1acd871e61238597ea92046809e3358290ff14d6ba671b449085
doc/orsetto.cbor/Cbor_event/index.html
Module Cbor_event
Concise Binary Object Representation (CBOR) events.
Overview
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
The type of indefinite-length sequencing signals.
The type of IEEE-754 floating point number precision.
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.
Constructors
val int_to_minor : int -> minor
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.
val minor_to_intopt : minor -> int option
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.
val null : t
The distinguished "null" value.
val boolean : bool -> t
Use boolean b
to select either the distinguished "true" or "false" event according to b
.
Use integer sign minor
to make a positive or negative integer event, according to sign
, with the value minor
.
val float : ?precision:[< ieee754_precision ] -> float -> t
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.
val octets : string -> t
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.
val text : string -> t
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.
Utilities
Equivalence relation
include Cf_relations.Equal with type t := t
val force_precision : [< ieee754_precision ] -> float -> float
Use force_precision p n
to truncate n
for the precision p
.