Standard Library
Vex's standard library. Prelude (auto-imported) plus explicitly imported packages.
For a practical learning sequence, start with your first standard-library workflow, then return here to distinguish prelude names from package imports.
Prelude (Auto-Imported)
These are available everywhere without import:
Collections
| Type | Description |
|---|---|
Vec<T> | Dynamic array bound to its construction-time allocator region |
Map<K, V> | Hash map (SwissTable) |
Set<T> | Hash set |
string | Owning string with inline storage for small values |
str | Borrowed string view |
Smart Pointers
| Type | Description |
|---|---|
Box<T> | Compiler-managed heap ownership; sharing and thread safety are inferred automatically |
Ptr<T> | Typed pointer |
Span<T> | Non-owning pointer-and-length view; checked access does not validate its lifetime |
RawBuf | Raw byte buffer |
Layout | Checked allocation size and alignment |
Mem | Canonical low-level allocation and byte-operation namespace |
Limits | Target-aware compile-time integer minimum and maximum values |
Error & Optionality
| Type | Description |
|---|---|
Result<T, E> | Operations that can fail |
Option<T> | Values that may not exist |
Range<T> | Range expressions |
Complex<T> | Complex numbers |
Packages (Import Required)
Memory primitives are deliberately absent from this list: there is no std/mem package. Low-level code uses the prelude Mem.* boundary; most code uses owning types such as Box, Vec, or string.
Use each package's documented path, for example import { File } from "fs";. A heading such as “standard library” is not an instruction to prepend std/ to every import. Math, Bit, and Crypto are builtin namespaces; they do not require imports. The crypto package is distinct from the Crypto builtin namespace.
Choose a package by the task and data ownership you need. Each linked guide shows its imports, examples and specific input/output contracts.
| Area | Guide |
|---|---|
| Command-line programs | CLI, system, logging |
| Data structures and ordering | Collections, sort, filter |
| Errors and cancellation | Errors, context |
| Files and paths | File system |
| Byte streams and compression | I/O, compression |
| Structured data | Serde: JSON, TOML, YAML, CSV, CBOR and MessagePack |
| Text and parsing | Strings, strconv, Unicode, encoding |
| TCP and UDP | Networking |
| Web protocols | HTTP, URL, TLS, WebRTC |
| Regular expressions | Regex |
| Hashes, secrets and random values | Hash, crypto, randomness |
| Database access | Database |
| Time | Time |
| Locations and routes | Geo |
| Images, video and audio | Vips, media |
| Numeric/model computation | ML, inference |
| Version requirements | Semver |
| Reusable protocols and tests | Contracts, testing |
| Build language tools | IDE packages |
The standard library index lists the package families. Import paths come from the individual module guides, including focused submodule imports when a program needs only a parser, codec or transform.
Compose packages around ownership
A file-processing command can parse arguments with cli, read bounded input with fs, decode structured data with serde, sort records with sort and write its result through io. Keep parse and I/O errors typed until the CLI boundary. Use context when cancellation/deadline state must follow an operation.
For media work, vips operates on image pixels, media on explicit frame/audio layouts, and webrtc on encoded packets and presentation timing. Conversion between packages may copy into a new owner; it is not automatically a pointer transfer. The image/media guides show that boundary directly.