mirror of
https://github.com/ocaml-multicore/eio.git
synced 2025-07-20 00:01:05 -04:00
Compare commits
3 Commits
669c2e86c0
...
ee51b04408
Author | SHA1 | Date | |
---|---|---|---|
|
ee51b04408 | ||
|
c6067a9059 | ||
|
8da6a7d7f1 |
@ -12,8 +12,13 @@ module Lazy = Lazy
|
||||
module Pool = Pool
|
||||
module Exn = Exn
|
||||
module Resource = Resource
|
||||
module Flow = Flow
|
||||
module Buf_read = Buf_read
|
||||
module Flow = struct
|
||||
include Flow
|
||||
|
||||
let read_all flow =
|
||||
Buf_read.(parse_exn take_all) flow ~max_size:max_int
|
||||
end
|
||||
module Buf_write = Buf_write
|
||||
module Net = Net
|
||||
module Process = Process
|
||||
|
@ -60,7 +60,16 @@ module Std = Std
|
||||
module Resource = Resource
|
||||
|
||||
(** Byte streams. *)
|
||||
module Flow = Flow
|
||||
module Flow : sig
|
||||
include module type of Flow (** @inline *)
|
||||
|
||||
(** {2 Convenience wrappers} *)
|
||||
|
||||
val read_all : _ source -> string
|
||||
(** [read_all src] is a convenience wrapper to read an entire flow.
|
||||
|
||||
It is the same as [Buf_read.(parse_exn take_all) src ~max_size:max_int] *)
|
||||
end
|
||||
|
||||
(** Buffered input and parsing *)
|
||||
module Buf_read = Buf_read
|
||||
|
@ -241,7 +241,8 @@ Exception: End_of_file.
|
||||
|
||||
```ocaml
|
||||
# let bflow = R.of_flow mock_flow ~max_size:100 |> R.as_flow;;
|
||||
val bflow : Eio.Flow.source_ty Eio.Std.r = Eio__.Resource.T (<poly>, <abstr>)
|
||||
val bflow : Eio__Flow.source_ty Eio.Std.r =
|
||||
Eio__.Resource.T (<poly>, <abstr>)
|
||||
# next := ["foo"; "bar"]; read bflow 2;;
|
||||
+mock_flow returning 3 bytes
|
||||
+Read "fo"
|
||||
|
@ -108,6 +108,22 @@ Copying from src using `Read_source_buffer`:
|
||||
- : unit = ()
|
||||
```
|
||||
|
||||
## read_all
|
||||
|
||||
```ocaml
|
||||
# run @@ fun () ->
|
||||
let each = String.init 256 Char.chr in
|
||||
let data = List.init 40 (fun _ -> Cstruct.of_string each) in
|
||||
let got = Eio.Flow.read_all (mock_source data) in
|
||||
traceln "Input length: %d\nOutput length: %d\nEqual: %b"
|
||||
(Cstruct.lenv data) (String.length got) (String.equal got (Cstruct.copyv data));
|
||||
;;
|
||||
+Input length: 10240
|
||||
+Output length: 10240
|
||||
+Equal: true
|
||||
- : unit = ()
|
||||
```
|
||||
|
||||
## write
|
||||
|
||||
```ocaml
|
||||
|
Loading…
x
Reference in New Issue
Block a user