Module coil-stdlib

io::sync

The io functions return as soon as a stream is not ready. These helpers wait until the whole job is done, which is what most programs want. Inside a task, waiting lets the other tasks run.

use io::sync::{println};
use string::{format};

fn main() {
    println(format("%i items", 3))?;
}

Part of coil-stdlib. spool projects get it automatically; with plain coil, pass --root ~/.coil/stdlib/src.

Import what you use (use path::* is not allowed):

use io::sync::{write_all, read_exact};

Functions#

NameDescription
write_allWrites all of buf to s, waiting whenever the stream is not ready.
read_exactFills all of buf from s, waiting whenever no data is ready.
read_to_endReads from s until it ends and returns everything read.
accept_waitWaits for the next connection on a TCP listener and returns its stream.
recv_from_waitWaits for a UDP datagram, reads it into buf, and returns (bytes, sender host, sender port).
send_to_waitSends buf as one UDP datagram to host:port, waiting while the socket is not ready.
copyCopies the file src to dst.
printWrites s to standard output, without a newline.
printlnWrites s and a newline to standard output.
eprintlnWrites s and a newline to standard error.
read_lineReads one line from s, without its line ending (LF or CRLF).
↑ ↓ navigate ↵ open