Decode errors
The type for decode errors.
Corrupted (kind, data), an error occured while decodingdataforkind.Version (exp, fnd), a versioned decoder expected versionexpbut foundfnd
val pp_error : Stdlib.Format.formatter -> error -> unitpp_error ppf e prints an unspecified representation of e on ppf.
exception Error of errorRaised on decode errors.
Codecs
val v : kind:string -> enc:('a -> string) -> dec:(string -> 'a) -> 'a tv kind enc dec is a codec for value identified as kind using enc to encode and dec to decode.
val kind : 'a t -> stringkind c is c's kind.
val enc : 'a t -> 'a -> stringenc c is c's encoder.
val dec : 'a t -> string -> 'adec c is c's decoder. The decoder
- raises Error
in case of decode error
Base type codecs
val unit : unit tunit codecs a ().
val const : 'a -> 'a tconst v codecs the constant v.
val bool : bool tbool codecs booleans.
val int : int tint codecs integers.
val string : string tstring 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 ] tmsg codecs error messages.