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:

ModuleDescription
preludeAuto-imported basics for every Toka program
typesType definitions and limits
traitsCore traits (@Hash, @PartialEq, @PartialOrd)
charUnicode character handling and classification
strString slice operations
stringUTF-8 dynamic string type and views
bytesRead-only binary byte-stream view
memoryMemory management primitives
optionOption<T> type for nullable values
resultResult<T, E> type for error handling
taskFundamental 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:

ModuleDescription
libcPlatform-dependent C standard library API declarations and bindings
termiosLow-level Tty terminal mode and control attributes configuration
threadLower-level OS native thread interfaces
syncOS-level synchronization primitives and lock implementations
linux / macos / windowsPlatform-specific system calls and bindings

lib/std/ — Standard Library

Ready-to-use standard modules for application development:

ModuleDescription
vecDynamically growing sequential array container (Vec)
dequeDouble-ended queue based on ring buffers (VecDeque)
slabZero-copy generational slab allocator (Slab / SlabID)
hashmapHigh-performance hash table based map (HashMap)
hashsetHash table based unique element collection (HashSet)
btreemapB-Tree based ordered key-value map (BTreeMap)
btreesetB-Tree based ordered unique set (BTreeSet)
heapPriority queue implemented with max/min binary heap (BinaryHeap)
arenaRegion-based arena allocator for high performance allocation (Arena)
ringHigh throughput lock-free ring buffers (RingBuffer)
ioBuffered standard console I/O (stdin / stdout / println)
fsFile system read/write and directory metadata operations
pathCross-platform file path parsing and manipulation (Path / PathBuf)
envEnvironment variables, process arguments, and system context interaction
processSubprocess spawning, state control, and pipe communication
threadOS native thread management and lifecycle control (Thread)
syncThread synchronization primitives (Mutex / Condvar / WaitGroup)
atomicHardware-level atomic operations and lock-free sync primitives
channelThread message passing communication channel (channel / sync_channel)
taskCoroutine task scheduling, context management, and async runtime
asyncAsync task helpers and bounded task coordination
bytesOwned immutable byte buffers and zero-copy byte views
contextCancellation and deadline propagation
iterIterator protocols and adapters
randomOS-backed secure random bytes and deterministic PRNG support
signalCooperative process shutdown signal handling
netTCP & UDP socket network communication interfaces
mathCommon mathematical functions and limit constants
timeSystem time and monotonic durations (Duration / Instant)
fmtText formatting and debug printing utilities (Format)
errorCommon error traits (Error) and failure base definitions
panicRuntime 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:

ModuleDescription
logBasic logging utilities and severity filtering
net/httpHTTP client and server
net/stream / net/tlsOwner-carrying streams and TLS adapters
net/urlURL parsing
net/cookie / net/mime / net/sseHTTP-adjacent parsing, MIME, and server-sent events
net/websocketWebSocket client and server
serde/jsonJSON serialization
crypto/md5MD5 hashing
crypto/sha1SHA-1 hashing
crypto/sha256SHA-256 hashing
encoding/base64Base64 encoding and decoding
encoding/hexHexadecimal encoding and decoding
encoding/percentPercent encoding and decoding
data/csv / data/formCSV and form-data codecs
io/bufioBuffered advanced I/O streams (BufReader / BufWriter)
rand/randPseudo-random number generator and random utilities (Random)
trace/spanMethod execution timing and trace spans
cli/flagCLI flag parsing
metrics/prometheusPrometheus text exposition primitives
uuid/uuid / version/semverUUID and SemVer utilities
serde/tomlTOML 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:

  1. Zero dependencies — Everything is built with pure Toka and the LLVM backend
  2. Consistent API — Similar patterns across different modules
  3. Error-aware — Every fallible operation returns Result or Option
  4. Performant — Compiled to native code with no hidden overhead