Module Imandra_util.Serialize

Serialization

type 'a t
type compress = {
compress : bytes -> bytes;
decompress : bytes -> bytes;
}
val make : ?⁠encode:(('a -> 'b) * ('b -> 'a)) -> ?⁠compress:compress -> name:string -> unit -> 'a t
type flags = Stdlib.Marshal.extern_flags =
| No_sharing
| Closures
| Compat_32
val encode_bytes : ?⁠flags:flags list -> 'a t -> 'a -> bytes
val encode_str : ?⁠flags:flags list -> 'a t -> 'a -> string
val encode_chan : ?⁠flags:flags list -> Stdlib.out_channel -> 'a t -> 'a -> unit
val encode_fd_block : ?⁠flags:flags list -> poll_read:(unit -> Unix.file_descr list) -> chs:IO_chunk.t list -> Unix.file_descr -> 'a t -> 'a -> unit

Write the value to this channel. @params chs chunks to be flushed to the channel first

parameter poll_read

reads to poll regularly on the side

val encode_chunks : ?⁠flags:flags list -> ?⁠pool:IO_chunk.Pool.t -> ?⁠init:IO_chunk.t list -> 'a t -> 'a -> IO_chunk.t list
val decode_bytes : ?⁠off:int -> 'a t -> bytes -> ('a, string) Stdlib.result
val decode_str : 'a t -> string -> ('a, string) Stdlib.result
val decode_chan : ?⁠pool:IO_chunk.Pool.t -> Stdlib.in_channel -> 'a t -> ('a option, string) Stdlib.result
val decode_fd_block : ?⁠pool:IO_chunk.Pool.t -> poll_write:(unit -> Unix.file_descr list) -> Unix.file_descr -> 'a t -> ('a option, string) Stdlib.result
val decode_chunk : IO_chunk.t -> 'a t -> ('a option, string) Stdlib.result

Decode a chunk into at least one 'a. If it succeeds, returns Ok (Some x) where part of chunk has been consumed. If it needs more input, returns Ok None and leaves chunk untouched. Otherwise fails. In case of decoding failure, the state of the chunk is undefined.

val gzip : compress