include Binable.Sinclude Binable.S_only_functions with type t := tval bin_size_t : t Size.sizerval bin_write_t : t Write.writerval bin_read_t : t Read.readerval __bin_read_t__ : (int ‑> t) Read.readerThis function only needs implementation if t exposed to be a polymorphic variant.
Despite what the type reads, this does *not* produce a function after reading;
instead it takes the constructor tag (int) before reading and reads the rest of the
variant t afterwards.
val bin_shape_t : Shape.tval bin_writer_t : t Type_class.writerval bin_reader_t : t Type_class.readerval bin_t : t Type_class.tval length : t ‑> intFor performance's concern, we require caller of to_opaque and of_opaque_exn to
pass in the buf as the intermediate buffer for bin_prot conversion. These two
functions will write bytes into the buffer, but will not resize the buffer. So the
caller should prepare big enough buffer for their need.
For of_opaque_exn t, the minimum buffer size should be length t.
For to_opaque the necessary buffer size can be computed using size from
Type_class.writer or you can catch the exception Bin_prot.Common.Buffer_short
(although the latter is not very reliable because some custom bin_io
implementations raise a different exception).
Additional caveat: if the opaque blob is malformed/partial then of_opaque_exn
can read past the end of the blob, which can result in:
buf
rather than the contents of the blob)val to_opaque : buf:Common.buf ‑> 'a ‑> 'a Type_class.writer ‑> tval of_opaque_exn : buf:Common.buf ‑> t ‑> 'a Type_class.reader ‑> 'a