module Codec:sig..end
Codecs for communication between the topkg tool and topkg
description files.
type error =
| |
Corrupted of |
| |
Version of |
Corrupted (kind, data), an error occured while decoding
data for kind.Version (exp, fnd), a versioned decoder
expected version exp but found fndval pp_error : Format.formatter -> error -> unitpp_error ppf e prints an unspecified representation of e
on ppf.exception Error of error
type 'a t
'a.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 decoderError in case of
decode errorval dec_result : 'a t -> string -> 'a Topkg.resultdec c is like Topkg.Private.Codec.dec but doesn't raise. The exception is
turned into an error message using Topkg.Private.Codec.pp_error.val with_kind : string -> 'a t -> 'a twith_kind k c is c with kind k.val write : Topkg.fpath -> 'a t -> 'a -> unit Topkg.resultwrite f c v encodes value v with c to f.val read : Topkg.fpath -> 'a t -> 'a Topkg.resultread f c reads a value with c from f.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.val option : 'a t -> 'a option toption el codecs el options.val result : ok:'a t ->
error:'b t -> ('a, 'b) Topkg.r tresult ~ok ~error codecs ok, error results.val list : 'a t -> 'a list tlist el codecs el lists.val pair : 'a t ->
'b t -> ('a * 'b) tpair c0 c1 codecs c0, c1 pairs.val t3 : 'a t ->
'b t ->
'c t -> ('a * 'b * 'c) t
val t4 : 'a t ->
'b t ->
'c t ->
'd t -> ('a * 'b * 'c * 'd) t
val t5 : 'a t ->
'b t ->
'c t ->
'd t ->
'e t -> ('a * 'b * 'c * 'd * 'e) t
val alt : kind:string ->
('a -> int) -> 'a t array -> 'a talt tag cs codecs values by tagging them with tag and
using the corresponding codec in cs.Invalid_argument if Array.length cs > 256.val version : int -> 'a t -> 'a tversion num c versions codec c with number num.
On decode a version number mismatch raises an error
see Topkg.Private.Codec.error.val view : ?kind:string ->
('a -> 'b) * ('b -> 'a) ->
'b t -> 'a tview kind t c views t as c for codecing.val msg : [ `Msg of string ] tmsg codecs error messages.val result_error_msg : 'a t -> 'a Topkg.result tresult_error_msg ok codecs ok or error message results.val fpath : Topkg.Fpath.t tfpath codecs files paths.val cmd : Topkg.Cmd.t tcmd codecs command line fragments.