Bytesrw adapter for Eio
ocaml codec

metadata

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