package orsetto

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

A submodule containing logic for encoding CBOR messages from values of type Cf_type.opaque according to optional mode selectors.

type mode

The mode selectors for encoding CBOR messges from opaque values.

val mode : ?strings:[< `Octets | `Text ] -> unit -> mode

Use mode () to create a mode selector record for the opaque value encoder. Use any of the various optional parameters to set a mode selector to other than its default value. The modes are as follows:

  • strings: Controls how OCaml strings are encoded. The default is octets.
val value : ?mode:mode -> Cf_type.opaque -> unit t

Use value v to create the CBOR encoding of the opaque value v provided it was witnessed by a type valid for output. The following table describes the runtime type indications required for values emitted.

Scalars:

  • Cf_type.Unit: null
  • Cf_type.Bool: boolean
  • Cf_type.Int: integer
  • Cf_type.Int32: integer
  • Cf_type.Int64: integer
  • Cf_type.Float: integer
  • Cf_type.String: octets (or text if mode.strings = `Text)
  • Ucs_type.Text: text

Containers:

  • Cf_type.(Seq {i nym}): array
  • Cf_type.(Seq (Pair ({i nym}, {i nym}))): map
  • Cbor_type.(Tag ({i nym})): tag

...and...

  • Cf_type.Opaque: any of the above

Use the ~mode parameter to select modes other than the default.

Raises Invalid_argument if the witnessed type is not valid for output as a CBOR value.

Use model mode to make a modified primitive data render model for opaque values that uses mode to control its output formatting.