package lwt
Install
Dune Dependency
Authors
Maintainers
Sources
md5=763b9201c891f8c20ee02dec0af23355
sha512=35574743df40170a8d1676254952c060090421a40d5f8ad37a6691f4f8bb0e28fca61f5efff1050edc4f8a3ffa2f06a1e23d0c084c89bfc105c1235e249bbc75
doc/lwt.unix/Lwt_fmt/index.html
Module Lwt_fmt
Source
Format API for Lwt-powered IOs
This module bridges the gap between Stdlib.Format
and Lwt
. Although it is not required, it is recommended to use this module with the Fmt
library.
Compared to regular formatting function, the main difference is that printing statements will now return promises instead of blocking.
Returns a promise that prints on the standard output. Similar to Stdlib.Format.printf
.
Returns a promise that prints on the standard error. Similar to Stdlib.Format.eprintf
.
Formatters
Lwt enabled formatters
make_stream ()
returns a formatter and a stream of all the writing order given on that stream.
of_channel oc
creates a formatter that writes to the channel oc
.
Formatter printing on Lwt_io.stdout
.
Formatter printing on Lwt_io.stdout
.
make_formatter ~commit ~fmt
creates a new lwt formatter based on the Stdlib.Format.formatter
fmt
. The commit
function will be called by the printing functions to update the underlying channel.
get_formatter fmt
returns the underlying Stdlib.Format.formatter
. To access the underlying formatter during printing, it is recommended to use %t
and %a
.
Printing
flush fmt
flushes the formatter (as with Stdlib.Format.pp_print_flush
) and executes all the printing action on the underlying channel.
Low level functions
write_order oc o
applies the order o
on the channel oc
.