package orsetto
Install
Dune Dependency
Authors
Maintainers
Sources
sha512=9b654edb663ae697563f150824047052f3b1bf760398f24bce6350553f031f73c46b6337239a1acd871e61238597ea92046809e3358290ff14d6ba671b449085
doc/orsetto.cbor/Cbor_encode/index.html
Module Cbor_encode
Concise Binary Object Representation (CBOR) event and value encoders.
Overview
This module provides a
f_encode
scheme for CBOR events, and a system of schemes for emitting CBOR values as octet streams.
Events
val event : Cbor_event.t Cf_encode.scheme
The CBOR event encoder scheme. This scheme can encode most valid CBOR encodings.
Encoding Monad
A CBOR encoding is a unary monad.
include Cf_monad.Unary.Profile
Module inclusions from Cf_monad_core
and Cf_seqmonad
.
include Cf_monad.Core.Unary.Profile with type 'r t := 'r t
val return : 'r -> 'r t
Use return a
to apply the binding to a
.
module Affix : Cf_monad_core.Unary.Affix with type 'r t := 'r t
Open Affix
to include the affix monad operators.
Use disregard m
to ignore the value returned by m
and apply the unit value to the bound function.
module Infix = Affix
Deprecated module alias.
include Cf_seqmonad.Functor.Unary with type 'r t := 'r t
Use collect s
to bind in sequence every monad value in the finite sequence s
and collect all the returned values. Returns (n, s)
where n
is the number of values collected and s
is the list of values in reverse order, i.e. from last collected to first collected. Never returns and exhausts all memory if s
never terminates.
val null : unit t
The CBOR encoding of the null value.
val boolean : bool -> unit t
Use boolean b
to make the CBOR encoding of b
.
val integer : int -> unit t
Use integer n
to make the CBOR encoding of the integer value n
.
val int32 : ?sign:[< Cbor_event.sign ] -> int32 -> unit t
Use int32 n
to make the CBOR encoding of the `int32` value n
. Use the ~sign
argument to regard n
as unsigned rather than 2's-complement, and to explicitly control the arithmetic sign of the encoded integer.
val int64 : ?sign:[< Cbor_event.sign ] -> int64 -> unit t
Use int64 n
to make the CBOR encoding of the `int64` value n
. Use the ~sign
argument to regard n
as unsigned rather than 2's-complement, and to explicitly control the arithmetic sign of the encoded integer.
val float : ?precision:Cbor_event.ieee754_precision -> float -> unit t
Use float n
to make the CBOR encoding of the floating point value n
. If ~precision
is not provided, then the most precise form required to represent n
without loss is selected.
val octets : string -> unit t
Use octets s
to make the CBOR encoding of the octet sequence s
.
val text : Ucs_text.t -> unit t
Use text s
to make the CBOR encoding of the Unicode text s
.
Use array s
to compose the CBOR definite size array from the encodings in the list s
.
Use map s
to compose the CBOR definite size map containing the key-value pairs encoded in the list s
. Use the ~sort:()
option to sort the keys according to the deterministic encoding of CBOR.
Indefinite length sequences
Use octets_seq s
to make the CBOR encoding of the indefinite length octet sequence comprising the strings in s
.
val text_seq : Ucs_text.t Seq.t -> unit t
Use text_seq s
to make the CBOR encoding of the indefinite length Unicode text comprising the concatenation of the UTF-8 encoded fragments in s
.
Use array_seq s
to make the CBOR encoding of the indefinite length array comprising the elements encoded in s
.
Use map_seq s
to make the CBOR encoding of the indefinite length map comprising the key-value pairs encoded in s
.
Value Schemes
val scheme : ('v -> unit t) -> 'v Cf_encode.scheme
Use scheme f
to make the encoding scheme that applies f
to the emitted value to obtain the encoding of the sequence of CBOR events comprising its encoding.
Abstract Data
A specialization of the
f_data_render.Profile
for use with CBOR is provided here.
Containers with positional elements, e.g. vectors and records, are encoded as definite length CBOR arrays. Containers with indexed elements, e.g. tables and structures, are encoded as definite length CBOR maps.
module Render : sig ... end
A submodule to encapsulate functions for use with data rendering models.
Opaque Types
module Opaque : sig ... end
A submodule containing logic for encoding CBOR messages from values of type Cf_type.opaque
according to optional mode selectors.
Utility
val to_string : unit t -> string
Use to_string v
to make a string comprising the encoding of v
.
Deprecated
val value : Cf_type.opaque -> unit t
Use opaque v
to make the CBOR encoding of the opaque value v
. Raises Invalid_argument
if v
witnesses a type that cannot be encoded.