Standard library
The standard library is the set of modules under the reserved std namespace.
They are written in Plenty or expose existing compiler facilities, and are embedded in the compiler: importing one needs no
source installation, network, Cargo, or rustc. Native compilation still requires
the supported linker environment.
Using std.dataframe additionally requires its separately installed
optional native engine; unused imports need no engine.
A standard module must be imported. Names available without an import belong to the prelude and are specified under built-in facilities.
Modules
| Module | Contents | Error type |
|---|---|---|
std.actor | Supervised actors on one thread, each with its own heap, bounded mailbox and copied messages; a trap discards only that actor’s heap and files; timers, request-reply and restart | StartError, Undelivered[M], TimerError, RequestError[M] |
std.actor.net | TCP for actors: a listener that starts one actor per connection with admission limits, connections with bounded buffers, back-pressure and deadlines, and nonblocking connect and lookup | NetError, TimerError, BytesError |
std.actor.tls | TLS for actor connections: a std.tls session over a std.actor.net connection, with plaintext back-pressure and the session in the connection actor’s heap | TlsError, TimerError |
std.actor.http.server | HTTP/1.1 and HTTPS on isolated connection actors, bounded request/response handlers or resumable streaming events, deadlines and draining | ServerError |
std.archive | TAR and ZIP readers and writers over std.io, and extraction into a new directory under explicit path, link, and size limits | ArchiveError |
std.atomic | Inline atomic integers and booleans with compile-time checked orderings, and fences | None |
std.bytes | Compact owning byte buffers with checked ranges, explicit copies and validated text conversion | BytesError |
std.cache.lru | Fixed-capacity caches that evict the least recently used entry, with constant-time lookup, promotion and eviction | AllocError |
std.channel | Bounded channels, endpoints and selection | Channel/send/receive/selection errors |
std.cli | Explicit typed options/positionals, repeatable values, generated help and lossless path arguments | CliError |
std.cli.fileinput | Buffered fallible UTF-8 lines across native paths or command-line files, with stdin fallback | FileInputError |
std.cli.progress | Terminal-only stderr bars and spinners with counts, rates, ETA and throttled redraws | ProgressError |
std.collections | Owned binary heaps ordered by < or by a stored comparator | AllocError |
std.complex | Complex numbers over f64 with arithmetic operators, polar form, exp, log, sqrt, pow, and a+bi display | None |
std.compress | Bounded gzip, zlib, DEFLATE and Brotli compression of buffers and std.io streams, and CRC-32 | CompressError |
std.concurrent | Executors, futures and parallel operations | Pool/submission/future/parallel errors |
std.crypto | Digests, HMAC, BLAKE3 hashing/key derivation, constant-time comparison, AEAD encryption, Ed25519, X25519, and HKDF over std.bytes | CryptoError, AdvancedError |
std.csv | Streaming CSV readers and writers over std.io with explicit dialects, size limits, and positioned errors | CsvError |
std.dataframe | Optional Polars analytical expression plans, typed nullable columns, schema inspection, grouping, and CSV/Parquet I/O | DataFrameError |
std.db.kv | Ordered byte-key maps, atomic transactions and bounded scans over a versioned SQLite store | KvError |
std.db.sqlite | SQLite databases through prepared statements with typed parameters and reads, owned transactions that roll back on drop, and an explicit value-size limit | DbError |
std.deque | Owned generic ring buffers with constant-time removal at either end | AllocError |
std.diff | Line, word, character, byte, and list differences as edit operations, with Myers and patience algorithms and unified-diff output | AllocError |
std.encoding | Hex, base32/base64, MIME base64 and validated custom alphabets, plus fixed-width integer and IEEE 754 float packing with explicit byte order, over std.bytes | EncodingError |
std.env | Environment variables as text or bytes, a detached snapshot, and the working directory | IoError |
std.error | Explicit error mapping, operation/path context, descriptions, and standard-error reports | Mapper-selected error, Context[E], AllocError |
std.fmt | Writer-generic value/report formatting, bounded output and fallible strings | FormatError |
std.fs | Directories, metadata/walking, symbolic links and canonical paths, rooted mutation, owned temporary resources, bounded file/tree copy, metadata preservation, delete/glob | IoError, AllocError, WalkError, FsError, TreeCopyError |
std.fs.dirs | The home directory and the XDG configuration, cache, data, and state directories, from the environment | IoError |
std.fs.lock | Owned Linux shared/exclusive advisory locks, nonblocking and cancellable deadline acquisition | LockError |
std.fs.watch | Bounded Linux filesystem change batches, rename cookies, overflow and readiness waits | WatchError, WaitError |
std.graph | Directed and undirected graphs with node and edge data, stable handles, traversal, shortest paths, topological order, components and spanning trees | AllocError, GraphError |
std.http | Bounded HTTP/1.1 message heads and streamed Content-Length, chunked, and close-delimited bodies over std.io streams | HttpError |
std.http.decoder | Resumable bounded HTTP/1.x request framing over caller-supplied bytes, without I/O | HttpError |
std.http.body | Bounded request bodies for handlers: URL-encoded forms, JSON, and multipart uploads into unnamed temporary files | BodyError |
std.http.client | HTTP/1.1 client: pooled connections, deadlines and cancellation, bounded redirects, an explicit proxy, and replay of idempotent requests only | ClientError |
std.http.cookie | Cookie fields read leniently and Set-Cookie fields validated against injection, with secure defaults | CookieError |
std.http.files | Static files below a Root, opened one segment at a time without following links, with media types and conditional requests | FilesError |
std.http.https | std.http.client for https URLs through std.tls, verified by default, with CONNECT tunnels through a proxy | ClientError |
std.http.proxy | The client address and scheme behind explicitly trusted reverse proxies; deployment guidance | ProxyError |
std.http.server | HTTP/1.1 server: routing, a bounded worker pool and admission queue, idle connections parked off the workers, per-phase deadlines, and graceful shutdown | ServerError |
std.http.sse | Server-Sent Events from a server exchange: event, id, multi-line data, comments and retry, flushed per event, with disconnect and shutdown detection | SseError |
std.http.tls | std.http.server over std.tls, with handshake deadlines | ServerError |
std.http.typed | Typed head parsing and writes, fixed/chunked/close-delimited bodies, and guarded connection recovery with concrete causes and progress | FramingError[E], Partial[E] |
std.http.websocket | RFC 6455 WebSocket connections: the handshake as a server exchange or a ws client, bounded framed messages, pings and the closing handshake | WebSocketError |
std.http.wss | std.http.websocket clients for wss URLs through std.tls | WebSocketError |
std.image | Owned 8-bit pixel buffers, bounded PNG decoding and encoding, cropping, colour conversion and resizing | ImageError |
std.io | Partial-progress byte stream contracts, retry helpers, fixed-capacity buffering, file and process-stream adapters, and checked sequential binary fields in an owned memory cursor | StreamError, Partial, CopyError, CloseError, BinaryError |
std.io.typed | Byte stream protocols that carry a caller-chosen error type, buffering, adapters for std.io streams, and exact read, write, and copy helpers | StepError[E], Partial[E], CopyFailure[R, W] |
std.json | Strict JSON under depth, input, and output limits: resumable event decoder, validating encoder, and a value tree | JsonError |
std.jwt | JSON Web Tokens: compact JWS signing and verification with the algorithm fixed by the key, strict decoding, and explicit-clock claim checks | JwtError |
std.log | Leveled events with typed fields, delivered to caller-chosen sinks: logfmt lines, bounded memory, or a nonblocking channel | LogError |
std.markdown | CommonMark 0.31.2 parsing into events and HTML rendering, under input, depth, and output limits | MarkdownError |
std.template | Bounded Jinja-style text templates with explicit JSON values, HTML escaping, conditions, loops and named inheritance | TemplateError |
std.math | Floating-point functions, checked rounding, integer algorithms, integer and float helpers, and constants | MathError, OverflowError[T] |
std.mime | Media types: RFC 9110 parsing and formatting with parameters, media-range matching, and the file-extension table | ParseError, AllocError |
std.net | TCP listeners and streams, UDP sockets, IP addresses and name lookup, with deadlines and cancellation | NetError |
std.path | Lossless Linux paths, lexical operations, checked text conversion and escaped display | IoError, AllocError |
std.process | Children spawned from an argument vector with no implicit shell, piped streams, bounded output collection, signals, and explicit reaping | IoError, StreamError |
std.random | Caller-owned seeded generators with unbiased ranges, shuffling, and index sampling; not for secrets | RandomError |
std.ready | Readiness waits on pipes and other handles, bounded by a deadline and a cancellation token | WaitError |
std.regex | Linear-time regular expressions over text and bytes: search, captures, iteration, split, and replacement under explicit pattern, memory, and work limits | RegexError |
std.report | Bounded human-readable report rendering with std.fmt | FormatError |
std.secrets | Operating-system entropy: secret bytes, hex and base64url tokens, and unbiased integers, with no fallback source | SecretsError |
std.shlex | Shell-style word splitting and POSIX argument quoting, without execution or expansion | ShlexError, AllocError |
std.sketch | Bounded distinct counts, sampled quantiles and frequent-item bounds with versioned checkpoints | SketchError, AllocError, BytesError |
std.sketch.xor | Static approximate membership over numeric identities with bounded construction | SketchError, AllocError, BytesError |
std.sketch.cuckoo | Scalable approximate membership with bounded growth and receipt-directed deletion | SketchError, AllocError, BytesError |
std.signal | SIGTERM and SIGINT as an event to wait or select on, and a helper that cancels a token on one | SignalError, WaitError |
std.simd | Portable fixed-lane values, masks, checked and wrapping arithmetic, selection, and bounded list loads/stores | None |
std.stat | Descriptive f64 statistics, inclusive quantiles, and normal, uniform and exponential distributions with explicit RNG sampling | StatError |
std.plot | Layered charts from owned columns or record accessors, validated mappings, grouped statistics, and deterministic streaming SVG | PlotError |
std.linalg | Dense f64 matrices, products, solves, LU, QR, Cholesky, SVD and eigen decompositions through an optional faer engine | AllocError, LinalgError |
std.sync | Shared cooperative cancellation tokens | AllocError |
std.system | Bounded Linux procfs snapshots: CPUs, memory, load, uptime, block devices, disk I/O and process status | IoError, SystemError |
std.tempfile | Unnamed and named temporary files, recursively cleaned directories, context managers and explicit ownership transfer | IoError, FsError, StreamError, AllocError |
std.test | Assertions that explain their failure on standard error, self-removing scratch directories, the seeded generator for plenty test, and fake clocks and streams | TestError |
std.text | Bounded builders, joining, scalar/word wrapping, shortening, and indentation | TextError |
std.thread | Explicit scoped thread and owned-job imports | ThreadError, SpawnError[F] |
std.time | Checked durations, monotonic instants and deadlines, wall timestamps, and sleep | RangeError |
std.tls | TLS 1.2 and 1.3 client and server streams over std.net TCP, with verified certificates, client certificates, ALPN, deadlines, and cancellation | TlsError |
std.toml | Strict TOML 1.0 parsing, value-tree writing and format-preserving document edits, under depth, input, and output limits | TomlError |
std.unicode | Unicode 17 normalization, combining classes, and Mark classification | TextError |
std.units | SI dimensions, prefixed and common units, physical constants, and dimension-aware square roots, sums and trigonometry over Quantity | MathError, RangeError |
std.units.catalogue | Every SI prefix on every SI unit and the other named units of NIST SP 811 | None |
std.url | Strict RFC 3986 absolute URL parsing and formatting without normalization, component-aware percent encoding, and query pairs | UrlError |
std.uuid | UUID values, canonical text and network bytes, random v4 and timestamp-prefixed v7 generation | ParseError, BytesError, SecretsError, RangeError |
std.xml | Bounded UTF-8 XML event readers and validating stream writers, without DTDs or external entities | XmlError |
The generated signature index lists every public declaration of every module on one page. Standard library conventions states the naming, error, parameter and type rules public modules follow, and where modules still differ.
Planned modules appear only in the backlog. The tutorial introduces the library in Use the standard math library, Enumerate and classify paths, and Prune before descending.
Importing a standard module
Standard modules use the ordinary import forms:
import std.math
import std.math as math
from std.math import sqrt, pi
from std.math import MathError as Error
An import binds only the names it lists. import std.math requires the full
std.math.sqrt qualification; an alias shortens it.
std is reserved. Each of these is an error:
- a
stddirectory,std.plenty, orstd.plentyiin the source root; - a declaration named
std; - an import that binds a non-standard module as
std.
An unknown standard module, including a bare import std, is an error that
lists the available modules. It never falls back to a local file.
How standard modules are compiled
A standard module passes through ordinary parsing, visibility checks, type
checking, specialization, and native emission. Its private helpers stay private.
Repeated imports, through any alias or dependency path, share its nominal
types, so a MathError from one module equals a MathError from another.
The scope rationale
records when a module uses a native library instead of Plenty source.
The four concurrency modules export canonical builtin identities instead of wrapper functions. Their imports reach the existing ownership and worker checks directly, including scoped joins and blocking-wait diagnostics. Their prelude spellings remain available. Importing one of these under its own builtin name is permitted only when it denotes the same builtin; unrelated name collisions remain errors. Generic constructor and error aliases retain the same types.
Embedded modules have toolchain identities such as std/math.plenty,
independent of the installation path. A diagnostic located inside a standard
module, such as a note on a generic helper instantiated with an unsupported
type, uses that name. The source-only APIs (check_source, compile_source_*)
have no source root, so they can import std modules but not project modules.
The runtime packaging page describes how the sources ship with the compiler.
Reading a module page
Each module page gives every public function’s signature and states:
- whether it returns a plain value or a
Result, and which error variants it reports; - whether it borrows or consumes its arguments;
- whether it allocates;
- the limits that differ from the Python module of the same name.
Recoverable failures use typed errors: std.math defines MathError, while
std.path and std.fs share the native IoError and storage AllocError.
The filesystem walker adds WalkError to retain attempted paths and operations.
? propagates an error to a caller returning the same error type or
Failure.
std.error states the conventions modules follow for typed causes,
native codes, and allocation failure. Module functions accept
named arguments and defaults;
the signature index shows each default.
Acknowledgements
- The breadth of Python’s standard library motivated the module catalogue.