package orsetto

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

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

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
type +'r t

The abstract type of a monad.

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.

val bind : 'a t -> ('a -> 'b t) -> 'b t

Use bind m f to bind f to the value returned by m.

val product : 'a t -> 'b t -> ('a * 'b) t

Use product a b to return the monoidal product of a and b.

module Affix : Cf_monad_core.Unary.Affix with type 'r t := 'r t

Open Affix to include the affix monad operators.

val disregard : 'r t -> unit t

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
val collect : 'r t Seq.t -> (int * 'r list) 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 serial : unit t Seq.t -> unit t

Use serial s to bind in sequence every monad value in the sequence s.

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.

val array : unit t list -> unit t

Use array s to compose the CBOR definite size array from the encodings in the list s.

val map : ?sort:unit -> (unit t * unit t) list -> unit t

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.

val tagged : int64 -> unit t -> unit t

Use tagged n v to make the CBOR encoding of v tagged with n

Indefinite length sequences
val octets_seq : string Seq.t -> unit t

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.

val array_seq : unit t Seq.t -> unit t

Use array_seq s to make the CBOR encoding of the indefinite length array comprising the elements encoded in s.

val map_seq : (unit t * unit t) Seq.t -> unit t

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.

  • deprecated Use Opaque.value instead!
OCaml

Innovation. Community. Security.