Legend:
Library
Module
Module type
Parameter
Class
Class type
HeXDump library for OCaml.
The library provides the most abstract way to serialize something to a human-readable hexdump. It allows the transmission of binary data in a `mail-safe' ASCII representation and it can handle colors if the given Format.formatter supports it.
It permits to serialize to a caml value as a simple list of strings or an array of strings.
caml ?with_comments ?cols ?long ?uppercase k returns a configuration which can be used by generate then. It allows to produces a caml value from something.
cols: octets per line (default to 16)
with_comments: add a comment which pretty-line the group in a comment
long: stop after reading len octets.
k: if the user wants to produce a list of strings or an array of strings.
val generate :
cfg->'sscheduler->('i, bytes, 's, 'e)input->('o, string, 's, 'e)output->'i->'o->('i, 's, 'e)seek->[ `Absolute of int| `Relative of int ]->Stdlib.Format.formatter ->((unit, 'e)Stdlib.result, 's)io
generate cfg scheduler input output ic oc seek pos ppf is the most abstract way to produce an hex-dump output. According to arguments, we are able to read into ic and write into oc with respectively input and output.
seek is used to manipulate the position in ic according to the given position pos.
ppf is used to know if we support colors or not. generate writes on it too and it takes care about pretty-printing boxes.
scheduler depends on which scheduler you use. You need to create one over monads:
module Unix_scheduler = Hxd.Make(struct type 'a t = 'a end)
let unix_scheduler =
let open Unix_scheduler in
{ Hxd.bind= (fun x f -> f (prj x))
; return= inj }
generate cfg unix_scheduler ...
You can abstract LWT monads too:
module Lwt_scheduler = Hxd.Make(struct type 'a t = 'a Lwt.t end)
let lwt_scheduler =
let open Lwt.Infix in
let open Lwt_scheduler in
{ Hxd.bind= (fun f x -> inj (prj x >>= fun x -> prj (f x)))
; return= (fun x -> inj (Lwt.return x)) }
generate cfg lwt_scheduler