Decode errors
The type for decode errors.
Corrupted (kind, data)
, an error occured while decodingdata
forkind
.Version (exp, fnd)
, a versioned decoder expected versionexp
but foundfnd
val pp_error : Stdlib.Format.formatter -> error -> unit
pp_error ppf e
prints an unspecified representation of e
on ppf
.
exception Error of error
Raised on decode errors.
Codecs
val v : kind:string -> enc:('a -> string) -> dec:(string -> 'a) -> 'a t
v kind enc dec
is a codec for value identified as kind
using enc
to encode and dec
to decode.
val kind : 'a t -> string
kind c
is c
's kind.
val enc : 'a t -> 'a -> string
enc c
is c
's encoder.
val dec : 'a t -> string -> 'a
dec c
is c
's decoder. The decoder
- raises Error
in case of decode error
Base type codecs
val unit : unit t
unit
codecs a ()
.
val const : 'a -> 'a t
const v
codecs the constant v
.
val bool : bool t
bool
codecs booleans.
val int : int t
int
codecs integers.
val string : string t
string
codecs strings.
t5
is like pair
but for qintuples.
alt tag cs
codecs values by tagging them with tag
and using the corresponding codec in cs
.
- raises Invalid_argument
if
Array.length cs > 256
.
version num c
versions codec c
with number num
. On decode a version number mismatch raises an error see error
.
view kind t c
views t
as c
for codecing.
Topkg types
val msg : [ `Msg of string ] t
msg
codecs error messages.