Bytesrw adapter for Eio
ocaml
codec
1(*---------------------------------------------------------------------------
2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
3 SPDX-License-Identifier: ISC
4 ---------------------------------------------------------------------------*)
5
6(** Bytesrw adapters for Eio
7
8 This module provides adapters to create {!Bytesrw.Bytes.Reader.t} and
9 {!Bytesrw.Bytes.Writer.t} from Eio flows, mirroring the API of
10 {!Bytesrw_unix} for Eio's effect-based I/O.
11
12 Unlike the Buf_read/Buf_write wrappers, these adapters read and write
13 directly to the flow, allowing bytesrw to handle its own buffering. *)
14
15(** {1 Readers} *)
16
17val bytes_reader_of_flow :
18 ?slice_length:int ->
19 _ Eio.Flow.source ->
20 Bytesrw.Bytes.Reader.t
21(** [bytes_reader_of_flow flow] creates a reader from an Eio source flow.
22
23 Reads directly from the flow without intermediate buffering.
24
25 @param slice_length Maximum bytes per slice (default: 65536) *)
26
27(** {1 Writers} *)
28
29val bytes_writer_of_flow :
30 ?slice_length:int ->
31 _ Eio.Flow.sink ->
32 Bytesrw.Bytes.Writer.t
33(** [bytes_writer_of_flow flow] creates a writer from an Eio sink flow.
34
35 Writes directly to the flow without intermediate buffering.
36
37 @param slice_length Suggested slice length for upstream (default: 65536) *)