Something went wrong. Try again.
Eio flows with progress bars
Something went wrong. Try again.
1.7 kB · 58 lines
OCaml
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859(** Eio flows with progress bars.
This library provides primitives for using {! Progress} with {! Eio}. The {! Path} and {! Net} modules are drop-in replacements for some functions in {! Eio.Path} and {! Eio.Net}. *)
type 'a report = 'a -> unit(** A reporter *)
(** {2 Displays}
Progress must be reported to a display. Displays are created and finalised like other resources in {! Eio}, i.e., with an {! Eio.Switch.t}. *)
type display(** Displays for flows *)
val with_display : ?config:Progress.Config.t -> (display -> 'a) -> 'a(** [with_display fn] runs [fn] with a new display. This display is also added to the fiber local storage so there is no need to thread it through to functions like {! Path.load}, although you can and save the fiber-local lookup. *)
(** {2 Flows} *)
val of_source : ?message:string -> ?size:int64 -> ?report:int report -> ?display:display -> 'a Eio.Flow.source -> 'a Eio.Flow.source(** [of_source src] converts [src] into a flow that tracks the {e progress} of reading the source. *)
val of_sink : int report -> 'a Eio.Flow.sink -> 'a Eio.Flow.sink(** [of_sink sink] converts [sink] into a flow that tracks the {e progress} of writing to the sink. *)
(** {2 Paths} *)
module Path : sig val load : ?bar:int64 Progress.Line.t -> ?display:display -> _ Eio.Path.t -> string (** An alternative to {! Eio.Path.load} that tracks the progress of loading a file. *)
val save : ?bar:int64 Progress.Line.t -> ?display:display -> ?append:bool -> create:Eio.Fs.create -> _ Eio.Path.t -> string -> unit (** An alternative to {! Eio.Path.save} that tracks the progress of the save. *)end