From 3ad8bc169fee68fad5b387f5099f38f8d2f85160 Mon Sep 17 00:00:00 2001 From: Patrick Ferris Date: Wed, 16 Aug 2023 14:52:04 +0100 Subject: [PATCH] Support eio.0.11 and beyond (#53) * Support eio.0.11 and beyond * Changes --- CHANGES.md | 6 +++++- README.md | 9 ++++----- bench/bench.ml | 2 +- src/geojsone/vendor/ezjsone/ezjsone.ml | 2 +- test/geojsonm/expect/test.ml | 2 +- test/geojsonm/expect/test_iters.ml | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index eded2fd..2a83b18 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ -# v0.1.0 (29/10/2022) Cambridge +# v0.1.1 2023-08-16 Cambridge + + - Work with eio.0.11 and hopefully beyond (#53 @patricoferris) + +# v0.1.0 2022-10-29 Cambridge Initial release \ No newline at end of file diff --git a/README.md b/README.md index 30e6983..9f08f1a 100644 --- a/README.md +++ b/README.md @@ -135,16 +135,15 @@ val buffer_to_dst : Buffer.t -> Cstruct.t -> unit = For reading, we can turn an arbitrary Eio `Flow.t` into a source. A `Flow.t` is a byte-stream so a file, a socket etc. ```ocaml -# let src_of_flow flow = +let src_of_flow flow = let buff = Cstruct.create 2048 in fun () -> - let got = Eio.Flow.(read flow buff) in + let got = Eio.Flow.(single_read flow buff) in let t = Cstruct.sub buff 0 got in - t;; -val src_of_flow : #Eio.Flow.source -> unit -> Cstruct.t = + t ``` -Note that your source function should raise `End_of_file` when there are no more bytes to be read. `Eio.Flow.read` does this. +Note that your source function should raise `End_of_file` when there are no more bytes to be read. `Eio.Flow.single_read` does this. With both of these we can now construct an encoder and decoder. diff --git a/bench/bench.ml b/bench/bench.ml index 9f57c39..7793f87 100644 --- a/bench/bench.ml +++ b/bench/bench.ml @@ -19,7 +19,7 @@ let read_write decode encode = let src_of_flow flow = let buff = Cstruct.create 65536 in fun () -> - let got = Eio.Flow.(read flow buff) in + let got = Eio.Flow.(single_read flow buff) in let t = Cstruct.sub buff 0 got in t diff --git a/src/geojsone/vendor/ezjsone/ezjsone.ml b/src/geojsone/vendor/ezjsone/ezjsone.ml index ca71475..c66fc2e 100644 --- a/src/geojsone/vendor/ezjsone/ezjsone.ml +++ b/src/geojsone/vendor/ezjsone/ezjsone.ml @@ -198,7 +198,7 @@ let src_of_string str = let buff = Cstruct.create (String.length str) in let src = Flow.string_source str in fun () -> - let got = Flow.(read src buff) in + let got = Flow.(single_read src buff) in let t = Cstruct.sub buff 0 got in t diff --git a/test/geojsonm/expect/test.ml b/test/geojsonm/expect/test.ml index af0a64c..dee4c45 100644 --- a/test/geojsonm/expect/test.ml +++ b/test/geojsonm/expect/test.ml @@ -23,7 +23,7 @@ let get_name = function let src_of_flow flow = let buff = Cstruct.create 2048 in fun () -> - let got = Eio.Flow.(read flow buff) in + let got = Eio.Flow.(single_read flow buff) in let t = Cstruct.sub buff 0 got in t diff --git a/test/geojsonm/expect/test_iters.ml b/test/geojsonm/expect/test_iters.ml index b155713..1c3111b 100644 --- a/test/geojsonm/expect/test_iters.ml +++ b/test/geojsonm/expect/test_iters.ml @@ -6,7 +6,7 @@ let print_property prop = print_endline @@ Geojsone.Ezjsone.value_to_string prop let src_of_flow flow = let buff = Cstruct.create 2048 in fun () -> - let got = Eio.Flow.(read flow buff) in + let got = Eio.Flow.(single_read flow buff) in let t = Cstruct.sub buff 0 got in t