You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Construct values of `Eio.Buf_read.t` and `Eio.Buf_write.t` when
converting `Lwt_io` code to Eio.
Code using `Lwt_io.read_into` is in-between using unbuffered and
buffered IO and should be changed. A comment is inserted.
(* TODO: lwt-to-direct-style: [buf] should be a [Cstruct.t]. *)
692
+
(* TODO: lwt-to-direct-style: [Eio.Flow.single_read] operates on a [Flow.source] but [inp] is likely of type [Eio.Buf_read.t]. Rewrite this code to use [Buf_read] (which contains an internal buffer) or change the call to [Eio.Buf_read.of_flow] used to create the buffer. *)
(* TODO: lwt-to-direct-style: [sw] (of type Switch.t) must be propagated here. *)
712
-
(* TODO: lwt-to-direct-style: This creates a closeable [Flow.sink] resource but write operations are rewritten to calls to [Buf_write]. You might want to use [Buf_write.with_flow sink (fun buf_write -> ...)]. *)
(* TODO: lwt-to-direct-style: [sw] (of type Switch.t) must be propagated here. *)
726
-
(* TODO: lwt-to-direct-style: This creates a closeable [Flow.sink] resource but write operations are rewritten to calls to [Buf_write]. You might want to use [Buf_write.with_flow sink (fun buf_write -> ...)]. *)
(* TODO: lwt-to-direct-style: [sw] (of type Switch.t) must be propagated here. *)
730
+
(* TODO: lwt-to-direct-style: Write operations to buffered IO should be moved inside [with_flow]. *)
731
+
fd
732
+
: [ `W | `Flow | `Close ] r)
733
+
(fun outbuf -> `Move_writing_code_here)
729
734
730
735
let _f out_chan = Eio.Buf_write.string out_chan "str"
731
736
let _ : Eio.Buf_write.t = Lwt_io.stdout
732
-
733
-
let _f chan =
734
-
Eio.Buf_read.line
735
-
(* TODO: lwt-to-direct-style: Argument to [Eio.Buf_read.line] is a [Flow.source] but it should be a [Eio.Buf_read.t]. Use [Eio.Buf_read.of_flow ~max_size:1_000_000 source]. *)
736
-
chan
737
+
let _f chan = Eio.Buf_read.line chan
737
738
738
739
let _f fname =
739
740
let fd =
740
-
Eio.Path.open_in ~sw
741
-
(Eio.Path.( / ) env#cwd
742
-
(* TODO: lwt-to-direct-style: [sw] (of type Switch.t) must be propagated here. *)
743
-
(* TODO: lwt-to-direct-style: [env] must be propagated from the main loop *)
744
-
fname)
741
+
Eio.Buf_read.of_flow ~max_size:1_000_000
742
+
(Eio.Path.open_in ~sw
743
+
(Eio.Path.( / ) env#cwd
744
+
(* TODO: lwt-to-direct-style: [sw] (of type Switch.t) must be propagated here. *)
745
+
(* TODO: lwt-to-direct-style: [env] must be propagated from the main loop *)
746
+
fname))
745
747
in
746
748
Eio.Resource.close fd
747
749
748
750
let _f fname =
749
751
let fd =
750
-
Eio.Path.open_out ~sw ~create:(`If_missing 0o666)
751
-
(Eio.Path.( / ) env#cwd
752
-
(* TODO: lwt-to-direct-style: [sw] (of type Switch.t) must be propagated here. *)
753
-
(* TODO: lwt-to-direct-style: [flags] and [perm] arguments were dropped. The [~create] was added by default and might not match the previous flags. Use [~append:true] for [O_APPEND]. *)
754
-
(* TODO: lwt-to-direct-style: [env] must be propagated from the main loop *)
(* TODO: lwt-to-direct-style: [sw] (of type Switch.t) must be propagated here. *)
756
+
(* TODO: lwt-to-direct-style: [flags] and [perm] arguments were dropped. The [~create] was added by default and might not match the previous flags. Use [~append:true] for [O_APPEND]. *)
757
+
(* TODO: lwt-to-direct-style: [env] must be propagated from the main loop *)
758
+
(* TODO: lwt-to-direct-style: Write operations to buffered IO should be moved inside [with_flow]. *)
0 commit comments