Standard Library Overview
Toka groups its shipped APIs by stability tier: language syntax, core/std, bundled stdx extensions, and independently versioned official packages. Treat the tables below as an overview; import only the modules your program needs.
Module Structure
The bundled SDK library is organized into four layers; qualified official packages are separate registry dependencies:
lib/core/ — Core Language Primitives
These modules provide the fundamental types and traits that the language itself depends on:
| Module | Description |
|---|---|
prelude | Auto-imported basics for every Toka program |
types | Type definitions and limits |
traits | Core traits (@Hash, @PartialEq, @PartialOrd) |
char | Unicode character handling and classification |
str | String slice operations |
string | UTF-8 dynamic string type and views |
bytes | Read-only binary byte-stream view |
memory | Memory management primitives |
option | Option<T> type for nullable values |
result | Result<T, E> type for error handling |
task | Fundamental coroutine execution runtime and task base |
lib/sys/ — Low-level System Primitives
These modules provide direct bindings and primitives interacting with the operating system and low-level runtime:
| Module | Description |
|---|---|
libc | Platform-dependent C standard library API declarations and bindings |
termios | Low-level Tty terminal mode and control attributes configuration |
thread | Lower-level OS native thread interfaces |
sync | OS-level synchronization primitives and lock implementations |
linux / macos / windows | Platform-specific system calls and bindings |
lib/std/ — Standard Library
Ready-to-use standard modules for application development:
| Module | Description |
|---|---|
vec | Dynamically growing sequential array container (Vec) |
deque | Double-ended queue based on ring buffers (VecDeque) |
slab | Zero-copy generational slab allocator (Slab / SlabID) |
hashmap | High-performance hash table based map (HashMap) |
hashset | Hash table based unique element collection (HashSet) |
btreemap | B-Tree based ordered key-value map (BTreeMap) |
btreeset | B-Tree based ordered unique set (BTreeSet) |
heap | Priority queue implemented with max/min binary heap (BinaryHeap) |
arena | Region-based arena allocator for high performance allocation (Arena) |
ring | High throughput lock-free ring buffers (RingBuffer) |
io | Buffered standard console I/O (stdin / stdout / println) |
fs | File system read/write and directory metadata operations |
path | Cross-platform file path parsing and manipulation (Path / PathBuf) |
env | Environment variables, process arguments, and system context interaction |
process | Subprocess spawning, state control, and pipe communication |
thread | OS native thread management and lifecycle control (Thread) |
sync | Thread synchronization primitives (Mutex / Condvar / WaitGroup) |
atomic | Hardware-level atomic operations and lock-free sync primitives |
channel | Thread message passing communication channel (channel / sync_channel) |
task | Coroutine task scheduling, context management, and async runtime |
async | Async task helpers and bounded task coordination |
bytes | Owned immutable byte buffers and zero-copy byte views |
context | Cancellation and deadline propagation |
iter | Iterator protocols and adapters |
random | OS-backed secure random bytes and deterministic PRNG support |
signal | Cooperative process shutdown signal handling |
net | TCP & UDP socket network communication interfaces |
math | Common mathematical functions and limit constants |
time | System time and monotonic durations (Duration / Instant) |
fmt | Text formatting and debug printing utilities (Format) |
error | Common error traits (Error) and failure base definitions |
panic | Runtime fatal error triggering, intercepting, and stack hooks |
lib/stdx/ — Bundled Extensions (stdx)
Bundled extensions provide the stable 1.0 HTTP, TLS, encoding, and data utilities. Their APIs are more focused than core/std, but they ship with the SDK rather than being third-party packages:
| Module | Description |
|---|---|
log | Basic logging utilities and severity filtering |
net/http | HTTP client and server |
net/stream / net/tls | Owner-carrying streams and TLS adapters |
net/url | URL parsing |
net/cookie / net/mime / net/sse | HTTP-adjacent parsing, MIME, and server-sent events |
net/websocket | WebSocket client and server |
serde/json | JSON serialization |
crypto/md5 | MD5 hashing |
crypto/sha1 | SHA-1 hashing |
crypto/sha256 | SHA-256 hashing |
encoding/base64 | Base64 encoding and decoding |
encoding/hex | Hexadecimal encoding and decoding |
encoding/percent | Percent encoding and decoding |
data/csv / data/form | CSV and form-data codecs |
io/bufio | Buffered advanced I/O streams (BufReader / BufWriter) |
rand/rand | Pseudo-random number generator and random utilities (Random) |
trace/span | Method execution timing and trace spans |
cli/flag | CLI flag parsing |
metrics/prometheus | Prometheus text exposition primitives |
uuid/uuid / version/semver | UUID and SemVer utilities |
serde/toml | TOML parsing and serialization |
Qualified Official Packages
Official packages are independently versioned, registry-resolved libraries rather than another standard-library tier. Current qualified packages include regex, router, sqlite, redis, postgres, compress, unicode, gui, and openai_compat. Add them with toka add <name> and rely on package.lock for the exact verified release.
Design Philosophy
Toka's standard library follows these principles:
- Zero dependencies — Everything is built with pure Toka and the LLVM backend
- Consistent API — Similar patterns across different modules
- Error-aware — Every fallible operation returns
ResultorOption - Performant — Compiled to native code with no hidden overhead