package orsetto
Install
Dune Dependency
Authors
Maintainers
Sources
sha512=9b654edb663ae697563f150824047052f3b1bf760398f24bce6350553f031f73c46b6337239a1acd871e61238597ea92046809e3358290ff14d6ba671b449085
doc/orsetto.cbor/Cbor_decode/Opaque/index.html
Module Cbor_decode.Opaque
A submodule containing logic for parsing CBOR messages to values of type Cf_type.opaque
according to optional mode selectors.
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 asUcs_text.t
(the default) or asstring
.
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
, orCf_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.
val model : mode -> Cf_type.opaque Cf_data_ingest.model
Use model mode
to make a modified primitive data ingest model for opaque values that uses mode
to control its input formatting.