std.io.write
Functions and types for working with Write
rs.
Types
Allows writing bytes to a sink. To ensure that all data has been written,
writes have to be paired with a flush
.
Values
let write_slice ?write : forall a . [Write a] -> a -> Array Byte -> Int -> Int -> IO Int
Write some bytes from a slice of an array into the writer. The bounds
of the slice are given by start
and end
as a half open range [start, end)
.
The function returns the number of bytes that have been written. If the slice
is not empty and the returned value is 0
, the writer will likely not accept
more data. It may accept more data in the future.
Like write_slice
, but tries to write all of buf
.
Writes the entire contents of buf
into writer
. The call will fail if writer
does not accept all of the data.
let write_string writer str : forall a . [Write a] -> a -> String -> IO ()
Writes the entire string into writer
. The call will fail if writer
does not accept all of the data.
Flushes the buffers of the writer, ensuring that all data has been written.
Wraps writer
in a Buffered
writer to provide buffering.
let buffered_with_capacity capacity writer : forall w . [Write w] -> Int -> w -> Buffered w
Wraps writer
in a Buffered
writer to provide buffering with the specified
buffer capacity.
#[implicit]
let write_buffered : forall w . [Write w] -> Write (Buffered w)
Allows writing bytes to a sink. To ensure that all data has been written,
writes have to be paired with a flush
.
#[implicit]
let disposable_buffered : forall w . [Disposable w] -> [Write w] -> Disposable (Buffered w)
A resource that has to be released after use, for example a file handle or a database connection.