Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

sys

The sys module provides access to operating system level functionality: files, sockets, processes, timers, and the netidx publish/subscribe system. Each kind of stream (a file, a TCP or TLS connection, stdio, a child process’s pipe) is its own type, and the Read, Lines, Write, Close and Seek traits give them the same operations; see sys::io.

ModulePurpose
sys::ioThe stream traits, stdin/stdout/stderr
sys::fsOpen files, directory operations, filesystem watching
sys::tcpTCP connect, listen, accept
sys::tlsUpgrade TCP streams to TLS
sys::processSpawn child processes, their pipes and exit status
sys::netNetidx publish/subscribe and RPC
sys::timeTimers and current time
sys::dirsPlatform-aware standard directory paths
mod io;
mod fs;
mod process;
mod tcp;
mod tls;
mod time;
mod net;
mod dirs;

/// the command line arguments. argv[0] names the program: the script
/// file, or a standalone binary's own path. A program an embedder runs
/// from source gets the arguments the embedder passes.
val args: fn() -> Array<string>;

/// join parts to path using the OS specific path separator
val join_path: fn(path: string, @args: [string, Array<string>]) -> string;

/// flush stdout/stderr and terminate the process with the given exit
/// code; a code outside 0..=255 exits with 1. The return type is fully polymorphic because the call never
/// actually returns; it fires when its argument produces a value, so
/// you can use it as the trailing expression of a program to make it
/// exit deterministically on completion.
val exit: fn(code: i64) -> 'a;