Closed Gau-thier closed 1 year ago
Sorry for long delay on this.
Indeed I can't see a unified documentation on writing custom instances.
Generally my advice would be to look at implementations in std.ml
and draw inspiration from them.
The relevant doc pieces that I found include: in write.mli:
(** Type of writer functions for the binary protocol. They take a buffer,
a write position and a value, and return the next position after
writing out the value. *)
type 'a writer = buf -> pos:pos -> 'a -> pos
sizer goes without the doc, but its purpose is to determine the size of the value that [write] will write.
read.mli
has this:
(** Type of reader functions for the binary protocol. They take a
buffer and a reference to a read position, and return the unmarshalled
value. The next buffer position after reading in the value will be
stored in the position reference. *)
type 'a reader = buf -> pos_ref:pos_ref -> 'a
A comment in binable.ml
mentions what __bin_read_t__
is about.
For shape, there's something in the "User defined bin_prot
" section in shape/README.md
, although you probably don't care too much about that.
This was fixed internally and will soon be pushed upstream.
Hi! First of all, thanks for this tool. It looks pretty great!
This issue has two purposes:
bin_read_t
instances.Broken link in readme.md
I was hoping to find some examples in the HTML doc mentioned in the readme.md, but the link leads to an HTTP 404.
Help on custom instances
I am trying to define custom
bin_read_t
instances:Cheers,
Gauthier