IO adapters (io::sync, io::file)

Non-blocking streams are the compiler virtual module io. This package adds blocking loops and whole-file helpers on top.

use io::{stdout, open};
use io::sync::{write_all, read_to_end};
use io::file::{read_text, write_text};

Structure concurrent IO with task::scope / spawn (IO inside a task parks it). For a one-off generator, task::block_on resumes it to completion. Tutorials: IO streams, Tasks.

io::sync#

Blocking helpers over L0 + wait_readable / wait_writable (src/io/sync.hy), not host natives.

FunctionNotes
write_all / read_exact / read_to_endPark on WouldBlock; write_all uses io::write_from
accept_waitaccept + wait_readable
recv_from_waitrecv_from + wait_readable
print / println / eprintlnUTF-8 stdout/stderr helpers
read_lineUntil LF (strips CR); None on EOF with no bytes
use io::{stdout};
use io::sync::{write_all};
use string::{format, to_bytes};

fn main() {
    write_all(stdout(), to_bytes(format("%i", 42)));
}

io::file#

FunctionNotes
read_bytes / write_bytesWhole file as Vec<byte>
read_text / write_textUTF-8 via virtual string::{from_bytes, to_bytes}

Synced from coil-stdlib/docs/io.md . Edit it there; changes reach this site on the next package sync.

↑ ↓ navigate ↵ open