Module Imandra_surface.Bin_ser

Binary serialization using Msgpck

type 'a iter = ('a -> unit) -> unit
val c : Imandra_util.Debug.Channel.t

debug channel

module Fmt = CCFormat
module M = Msgpck

Key for custom encoder/decoder definitions

module Key : sig ... end
type encoder_state
type decoder_state
and ('st, 'a) def_hook = {
h_prefix : string;
h_key : ('st'a) Key.t;
h_enc : encoder_state -> Key.univ -> M.t;
h_dec : 'st -> decoder_state -> M.t -> 'a;
}

A hook for side definitions of type 'a using a given key

val define_hook : ('st'a) def_hook -> unit

Add a decoding hook to all future encoders and decoders.

State for encoding

module Encoder_state : sig ... end
module Decoder_state : sig ... end
type 'a encoder = Encoder_state.t -> 'a -> M.t
type 'a decoder = Decoder_state.t -> M.t -> 'a

Encoding

val encode : st:Encoder_state.t -> 'a encoder -> 'a -> M.t
val m_to_string : M.t -> string
val m_to_buf : Stdlib.Buffer.t -> M.t -> unit
val to_string_single : st:Encoder_state.t -> 'a encoder -> 'a -> string

Encode the given M.t to a string, without side definitions

val to_buf_with_side_defs : ?⁠st:Encoder_state.t -> 'a encoder -> Stdlib.Buffer.t -> 'a -> unit
val to_string_with_side_defs : ?⁠st:Encoder_state.t -> 'a encoder -> 'a -> string

Encode side definitions and the given M.t to a string

val to_chan_with_side_defs : ?⁠st:Encoder_state.t -> 'a encoder -> Stdlib.out_channel -> 'a -> unit

Decoding

exception Dec_fail of string

Exception raised for decoding

val dec_fail : ('a, Stdlib.Format.formatter, unit, 'b) Stdlib.format4 -> 'a
val m_of_string : string -> (M.t, string) Stdlib.result
val m_of_string_exn : string -> M.t
val decode : st:Decoder_state.t -> 'a decoder -> M.t -> ('a, string) Stdlib.result
val decode_exn : st:Decoder_state.t -> 'a decoder -> M.t -> 'a

Same as decode but can fail. Catches Invalid_argument and re-raise as a decoding failure.

raises Dec_fail

in case of error

val of_string_with_side_defs : ?⁠st:Decoder_state.t -> 'a decoder -> string -> ('a, string) Stdlib.result

Try to read a string containing with a bunch of side definitions and a single msgpack for 'a t at the end

module U : sig ... end
module Ty : sig ... end
module T : sig ... end
module TM : sig ... end