Skip to content

Standard library reference

Every public declaration of the standard library, made by fels doc from the /// comments in lib/std. Standard library is the guide to it.

Module
std.aarch64 AArch64 instructions a kernel needs: exception vectors, system registers, barriers
std.atomics atomic ops; rmw returns the previous value; helpers are seq-cst
std.base32 rfc 4648; strict: padding as the codec says, lowercase ok, no whitespace
std.base64 rfc 4648; strict: padding as the codec says, one alphabet, no whitespace
std.bits bit twiddling on u32/u64
std.bitset bits 0..n-1, 64 per word, in an arena; index past the end panics
std.bufio buffered io::Reader/io::Writer wrappers; the caller owns the buffer
std.build build.fels defines build :: fn(b: Build); runs in the comptime VM
std.bytes le/be fixed-width ints at any offset in a byte slice; no alignment needed
std.c C abi type aliases for #extern; sized for win64 (LLP64, long is 32-bit)
std.cbor rfc 8949; writer emits preferred (shortest) forms, reader allocates nothing
std.cli flags, options, positionals and help text from one command description
std.color 32-bit rgba color
std.com COM/WinRT types as data (GUID, HRESULT, IUnknown, vtables); no OS calls
std.crypto sha-1/256/512 (fips 180-4), hmac (rfc 2104); not audited for adversarial use
std.csv rfc 4180 reader; sep ‘,’ ‘;’ or tab; LF/CRLF; skips empty lines and a bom
std.decimal exact decimals (money); coef / 10^scale, i64 coef, max 18 places
std.deque ring-buffer deque in an arena; O(1) push/pop at both ends; grows 2x
std.flate deflate both ways (rfc 1951), gzip (rfc 1952), zlib (rfc 1950)
std.float exp, ln, pow for f64 without libm (core::pow needs C’s pow); ~1e-15 relative
std.fmt padding, justified numbers and joining over io.Writer; number parsing
std.freestanding for a program built with –target freestanding, which has no os under it
std.fs sync files and folders; paths over 1023 bytes fail with path_too_long
std.hash non-crypto hashes (FNV-1a, CRC-32, Adler-32, XXH64), one-shot or streaming
std.heap bump arena; growable (64 KiB chunks), reserved, or over a fixed buffer
std.hex bytes <-> hex; encodes lowercase (or upper), decodes either case
std.http http/1.1 client and server bits over std.net; no tls; one request per connection
std.io Reader/Writer, std streams, FixedBuf, NullWriter, printing; no allocation
std.json rfc 8259; parse into an arena tree, write with Out
std.leb128 7-bit varints (wasm, dwarf, protobuf); padded forms ok, >64 bits fails
std.log leveled format logging to stderr or any io::Writer
std.map open-addressed maps/sets and SortedMap, all in an Arena; no per-entry frees
std.math f32 vectors, rects and scalar helpers for games; v2_/v3_ prefixes
std.mem slice helpers; generics take the element type first: copy(u8, dst, src)
std.net tcp/udp facade over net.os/addr/socket/tcp/udp; re-exports their types
std.net.addr ipv4 and socket addresses
std.net.dns hosts file + A queries over udp; std.net.resolve’s path on linux (no libc)
std.net.os raw socket layer under std.net; for options the higher layers lack
std.net.socket raw OS socket handle; options shared by tcp and udp
std.net.tcp TCP streams and listeners over socket.Socket
std.net.udp datagram sockets; send_to/recv_from, or connect once then send/recv
std.path pure path string ops; reads / and , writes SEP; builders take an *Arena
std.png rfc 2083 decode to RGBA8 and encode; all color types, depths, interlace, tRNS
std.pqueue arena binary heap; O(log n) push/pop; order = any type with less()
std.process pid, args, env vars, child processes and pipes
std.ptr pointer <-> address and alignment math (Fels has no pointer arithmetic)
std.rand xorshift64* prng; same seed, same sequence; not for crypto
std.regex linear-time Pike VM; UTF-8 runes, byte offsets, leftmost-first
std.serde JSON to and from any value via type_info; no per-type code
std.slice fn-pointer predicate helpers over []T (find, count_where, any, all, …)
std.sort in-place sorts (introsort, not stable; stable_* merge) and binary search
std.strings arena-backed StringBuilder (also a Writer) and byte-string helpers
std.sync locks, condvars, queues, channels, wait groups; every type is #sync
std.thread OS threads, Scope (joined at block end), Pool (parallel loops)
std.time wall/monotonic clocks, sleep, UTC and local calendar, dates, text formats
std.uefi the firmware’s services, for a program built with –target uefi
std.url rfc 3986 parsing, percent-encoding, query strings; parsed parts stay encoded
std.utf16 utf-8 <-> utf-16 (native order, no bom); malformed input fails, never repaired
std.utf8 strict utf-8 decode/encode/validate; a bad byte decodes as REPLACEMENT, len 1
std.vec growable arrays that bump-allocate from an arena; no per-element frees
std.winrt COM/WinRT init, activation, HSTRING; windows only (ole32, combase)
std.x86 x86-64 instructions a kernel needs: ports, interrupts, control registers, msrs
std.zip read and write .zip (stored or DEFLATE); also .docx, .xlsx, .jar, .epub