Bytesrw adapter for Eio
ocaml
codec
bytesrw-eio - OCaml Bytesrw adapters for Eio#
This OCaml library provides adapters to create Bytesrw.Bytes.Reader.t and
Bytesrw.Bytes.Writer.t from Eio flows, mirroring the API of Bytesrw_unix
for Eio's effect-based I/O.
Usage#
open Eio.Std
(* Create a reader from an Eio flow *)
let read_from_flow flow =
let reader = Bytesrw_eio.bytes_reader_of_flow flow in
(* Use reader with Bytesrw decoders *)
reader
(* Create a writer to an Eio flow *)
let write_to_flow flow =
let writer = Bytesrw_eio.bytes_writer_of_flow flow in
(* Use writer with Bytesrw encoders *)
writer
For custom slice sizes:
(* Specify custom slice length for reading *)
let reader flow = Bytesrw_eio.bytes_reader_of_flow ~slice_length:4096 flow
(* Specify custom slice length for writing *)
let writer flow = Bytesrw_eio.bytes_writer_of_flow ~slice_length:4096 flow
For random-access file reading:
(* Read from a specific offset in a file *)
let reader file = Bytesrw_eio.pread_reader ~offset:1024 file
Installation#
Install with opam:
$ opam install bytesrw-eio
If opam cannot find the package, it may not yet be released in the public
opam-repository. Add the overlay repository, then install it:
$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install bytesrw-eio
Documentation#
API documentation is available via:
opam install bytesrw-eio
odig doc bytesrw-eio
Licence#
ISC