package orsetto

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

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

type mode

The mode selectors for decoding CBOR messages to opaque values.

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

Use mode () to create a mode selector record for the opaque value decoder. 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 UTF8 texts are decoded, either as Ucs_text.t (the default) or as string.
val value : ?mode:mode -> unit -> Cf_type.opaque Annot.form t

A parser that recognizes any CBOR encoded value and produces an annotated value with encapsulated runtime type indication. The following table describes the runtime type indications produced for values decoded.

  • null: Cf_type.Unit
  • boolean: Cf_type.Bool
  • integer: Cf_type.Int, Cf_type.Int32, or Cf_type.Int64
  • float: Cf_type.Float
  • octets: Cf_type.String
  • text: Ucs_type.Text
  • array: Cf_type.(Seq Opaque)
  • map: Cf_type.(Seq (Pair (Opaque, Opaque))
  • tag: Cbor_type.(Tag Cf_type.Opaque))
  • reserved: Cbor_type.Reserved

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

Use the

bor_type

module for unpacking.

Note well: the array and map containers are sequences of untyped values, which must be unpacked recursively. Exceeding a maximum recursion depth of 1000 raises Bad_syntax.

Also: the tag container is a pair comprising a tag number and the typed value witnessed by the parameter of the Tag type.

Finally, integers decoded into Int unless the value is outside the range of valid OCaml integers, in which case the value is decoded as Int32 or Int64, whichever is smaller and yet still large enough to contain the decoded value.

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

OCaml

Innovation. Community. Security.