Bytesrw adapter for Eio
ocaml codec
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 70 lines 1.5 kB view raw view rendered
1# bytesrw-eio - OCaml Bytesrw adapters for Eio 2 3This OCaml library provides adapters to create `Bytesrw.Bytes.Reader.t` and 4`Bytesrw.Bytes.Writer.t` from Eio flows, mirroring the API of `Bytesrw_unix` 5for Eio's effect-based I/O. 6 7## Usage 8 9```ocaml 10open Eio.Std 11 12(* Create a reader from an Eio flow *) 13let read_from_flow flow = 14 let reader = Bytesrw_eio.bytes_reader_of_flow flow in 15 (* Use reader with Bytesrw decoders *) 16 reader 17 18(* Create a writer to an Eio flow *) 19let write_to_flow flow = 20 let writer = Bytesrw_eio.bytes_writer_of_flow flow in 21 (* Use writer with Bytesrw encoders *) 22 writer 23``` 24 25For custom slice sizes: 26 27```ocaml 28(* Specify custom slice length for reading *) 29let reader flow = Bytesrw_eio.bytes_reader_of_flow ~slice_length:4096 flow 30 31(* Specify custom slice length for writing *) 32let writer flow = Bytesrw_eio.bytes_writer_of_flow ~slice_length:4096 flow 33``` 34 35For random-access file reading: 36 37```ocaml 38(* Read from a specific offset in a file *) 39let reader file = Bytesrw_eio.pread_reader ~offset:1024 file 40``` 41 42## Installation 43 44Install with opam: 45 46```sh 47$ opam install bytesrw-eio 48``` 49 50If opam cannot find the package, it may not yet be released in the public 51`opam-repository`. Add the overlay repository, then install it: 52 53```sh 54$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git 55$ opam update 56$ opam install bytesrw-eio 57``` 58 59## Documentation 60 61API documentation is available via: 62 63``` 64opam install bytesrw-eio 65odig doc bytesrw-eio 66``` 67 68## Licence 69 70ISC