Bytesrw adapter for Eio
ocaml codec

metadata

+145 -4
+1
.ocamlformat
··· 1 + version=0.28.1
+49
.tangled/workflows/build.yml
··· 1 + when: 2 + - event: ["push", "pull_request"] 3 + branch: ["main"] 4 + 5 + engine: nixery 6 + 7 + dependencies: 8 + nixpkgs: 9 + - shell 10 + - stdenv 11 + - findutils 12 + - binutils 13 + - libunwind 14 + - ncurses 15 + - opam 16 + - git 17 + - gawk 18 + - gnupatch 19 + - gnum4 20 + - gnumake 21 + - gnutar 22 + - gnused 23 + - gnugrep 24 + - diffutils 25 + - gzip 26 + - bzip2 27 + - gcc 28 + - ocaml 29 + 30 + steps: 31 + - name: opam 32 + command: | 33 + opam init --disable-sandboxing -a -y 34 + - name: switch 35 + command: | 36 + opam install . --confirm-level=unsafe-yes --deps-only 37 + - name: build 38 + command: | 39 + opam exec -- dune build 40 + - name: switch-test 41 + command: | 42 + opam install . --confirm-level=unsafe-yes --deps-only --with-test 43 + - name: test 44 + command: | 45 + opam exec -- dune runtest --verbose 46 + - name: doc 47 + command: | 48 + opam install -y odoc 49 + opam exec -- dune build @doc
+15
LICENSE.md
··· 1 + ISC License 2 + 3 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org> 4 + 5 + Permission to use, copy, modify, and distribute this software for any 6 + purpose with or without fee is hereby granted, provided that the above 7 + copyright notice and this permission notice appear in all copies. 8 + 9 + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+57
README.md
··· 1 + # bytesrw-eio - Bytesrw adapters for Eio 2 + 3 + This 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. 4 + 5 + ## Key Features 6 + 7 + - **Direct flow integration**: Read and write directly to Eio flows without intermediate buffering 8 + - **Efficient I/O**: Allows Bytesrw to handle its own buffering strategy 9 + - **Simple API**: Minimal, straightforward interface matching Bytesrw_unix patterns 10 + 11 + ## Usage 12 + 13 + ```ocaml 14 + open Eio.Std 15 + 16 + (* Create a reader from an Eio flow *) 17 + let read_from_flow flow = 18 + let reader = Bytesrw_eio.bytes_reader_of_flow flow in 19 + (* Use reader with Bytesrw decoders *) 20 + reader 21 + 22 + (* Create a writer to an Eio flow *) 23 + let write_to_flow flow = 24 + let writer = Bytesrw_eio.bytes_writer_of_flow flow in 25 + (* Use writer with Bytesrw encoders *) 26 + writer 27 + ``` 28 + 29 + For custom slice sizes: 30 + 31 + ```ocaml 32 + (* Specify custom slice length for reading *) 33 + let reader = Bytesrw_eio.bytes_reader_of_flow ~slice_length:4096 flow in 34 + 35 + (* Specify custom slice length for writing *) 36 + let writer = Bytesrw_eio.bytes_writer_of_flow ~slice_length:4096 flow in 37 + () 38 + ``` 39 + 40 + ## Installation 41 + 42 + ``` 43 + opam install bytesrw-eio 44 + ``` 45 + 46 + ## Documentation 47 + 48 + API documentation is available via: 49 + 50 + ``` 51 + opam install bytesrw-eio 52 + odig doc bytesrw-eio 53 + ``` 54 + 55 + ## License 56 + 57 + ISC
+5
bytesrw-eio.opam
··· 3 3 synopsis: "Bytesrw readers and writers for Eio" 4 4 description: 5 5 "Provides Bytesrw.Bytes.Reader and Writer adapters for Eio Flows" 6 + maintainer: ["Anil Madhavapeddy <anil@recoil.org>"] 7 + authors: ["Anil Madhavapeddy"] 8 + license: "ISC" 9 + homepage: "https://tangled.org/@anil.recoil.org/ocaml-bytesrw-eio" 10 + bug-reports: "https://tangled.org/@anil.recoil.org/ocaml-bytesrw-eio/issues" 6 11 depends: [ 7 12 "dune" {>= "3.18"} 8 13 "ocaml" {>= "5.0"}
+10 -1
dune-project
··· 1 1 (lang dune 3.18) 2 + 2 3 (name bytesrw-eio) 3 4 4 5 (generate_opam_files true) 5 6 7 + (license ISC) 8 + (authors "Anil Madhavapeddy") 9 + (homepage "https://tangled.org/@anil.recoil.org/ocaml-bytesrw-eio") 10 + (maintainers "Anil Madhavapeddy <anil@recoil.org>") 11 + (bug_reports "https://tangled.org/@anil.recoil.org/ocaml-bytesrw-eio/issues") 12 + (maintenance_intent "(latest)") 13 + 6 14 (package 7 15 (name bytesrw-eio) 8 16 (synopsis "Bytesrw readers and writers for Eio") ··· 10 18 (depends 11 19 (ocaml (>= 5.0)) 12 20 (bytesrw (>= 0.2)) 13 - (eio (>= 1.0)))) 21 + (eio (>= 1.0)) 22 + (odoc :with-doc)))
+3 -3
src/bytesrw_eio.ml
··· 1 1 (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 5 6 6 (** Bytesrw adapters for Eio 7 7
+5
src/bytesrw_eio.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Bytesrw adapters for Eio 2 7 3 8 This module provides adapters to create {!Bytesrw.Bytes.Reader.t} and