Standard Library
Import modules with from "std/<name>" import { symbols }.
I/O & Filesystem
| Module | What it provides |
|---|---|
std/io | readFile, readStdin, File.openRead/.openWrite/.openAppend, f.readAll(), f.writeAll(), RAII file handles |
std/fs | readDir, fileInfo, isDir/isFile, pathExists, writeFile |
std/path | pathJoin, pathBasename, pathDirname, pathExt, pathStem |
std/env | getEnv, getEnvOr |
Networking
| Module | What it provides |
|---|---|
std/net | TCP, DNS, fetch with TLS |
std/http | HTTP server with Hono-style router, context, middleware |
Data
| Module | What it provides |
|---|---|
std/json | Zero-copy JSON parser — jsonParse, keyed accessors (.str(), .i64(), .f64(), .bool()), jsonStringify |
std/arena | Generational arena for cyclic/graph data with safe Handle<T> |
std/set | HashSet<T> — add, contains, remove |
CLI & System
| Module | What it provides |
|---|---|
std/argparse | CLI argument parsing with typed getters and --help generation |
std/args | Raw CLI arguments — args(), getFlag, hasFlag |
std/process | Command execution, Process.spawn/.wait()/.signal(), run, capture |
std/signal | POSIX signal handling — onSignal, ignoreSignal |
Data Formats
| Module | What it provides |
|---|---|
std/csv | CSV parsing with header support |
std/toml | TOML config parsing — tomlParse, .str(), .i64(), .table() |
std/base64 | Base64 encode/decode |
std/hex | Hex encode/decode |
Date, Time & IDs
| Module | What it provides |
|---|---|
std/time | Wall clock, monotonic timing, sleep |
std/datetime | Date/time from epoch — dateTimeNow, dateTimeFormat, weekdayName |
std/uuid | UUID v4 generation |
Concurrency
| Module | What it provides |
|---|---|
std/runtime | Task.spawn, Promise / Promise.blocking, green scheduler |
std/sync | Channel, WaitGroup, AtomicI64, AtomicBool — all method-based |
Database & Network
| Module | What it provides |
|---|---|
std/sqlite | SQLite3 bindings — dbOpen, dbQuery, dbExec, prepared statements |
std/url | URL parsing — urlParse, urlQueryGet |
Strings & Formatting
| Module | What it provides |
|---|---|
std/string | strContains, strSplit, strReplace, strTrim, case conversion |
std/fmt | Template formatting (fmt1–fmt4), padLeft/padRight, join |
std/strconv | parseInt, parseFloat, radix conversions, formatFloat |
std/unicode | Character classification — isDigit, isAlpha, toLowerChar |
Math & Random
| Module | What it provides |
|---|---|
std/math | abs, min, max, pow, sqrt, log, trig functions |
std/random | randInt, randFloat, randRange, shuffleI64 |
Utilities
| Module | What it provides |
|---|---|
std/color | ANSI terminal colors — red, green, bold, etc. |
std/regex | Regular expression matching — regexNew, regexMatch, regexFind |
std/sort | Sorting for Vec — sortI32, sortI64, sortStrings |
std/testing | assert, assertEqual, assertStrEqual |
std/log | Leveled logging to stderr — logDebug, logInfo, logWarn, logError |
std/mem | mmapAnon, mmapFile, bump-allocator arena |
Cryptography
OpenSSL-backed hashing plus pure-Milo hashing, MAC, and token modules (no C codec dependency; constant-time and WCET-analyzable).
| Module | What it provides |
|---|---|
std/crypto | sha256, sha1, md5, and aesGcmEncrypt/aesGcmDecrypt (128/256-bit AES-GCM) |
std/sha256 | Pure-Milo SHA-256 — sha256, sha256Bytes |
std/sha1 | Pure-Milo SHA-1 — sha1, sha1Bytes |
std/hmac | HMAC-SHA256 / HMAC-SHA1 — hmacSha256, hmacSha1Bytes |
std/jwt | JWT sign/verify (HS256) — jwtSignHS256, jwtVerifyHS256 |
std/totp | RFC 6238 TOTP / RFC 4226 HOTP one-time passwords — totp, hotp |
std/base32 | Base32 encode/decode (RFC 4648) — base32Encode, base32Decode |
Compression
Pure-Milo DEFLATE (RFC 1951) and the gzip / zlib / zip containers built on it.
| Module | What it provides |
|---|---|
std/deflate | Compress — raw DEFLATE, gzipCompress, zlibCompress |
std/inflate | Decompress — inflate, gzipDecompress, zlibDecompress |
std/zip | Read ZIP archives — zipRead (.zip/.jar/.epub/.docx) |
HTTP Server Example
milo
from "std/http" import { Context, Response, Router, serveRouter }
fn homeHandler(ctx: &mut Context): Response {
return ctx.html("<h1>Hello!</h1>")
}
fn jsonHandler(ctx: &mut Context): Response {
let name = ctx.query("name")
return ctx.json($"\{\"hello\": \"{name}\"}")
}
fn main(): i32 {
var r: Router = Router.new()
r.get("/", homeHandler)
r.get("/api", jsonHandler)
serveRouter(8080, r)
return 0
}Arena Example
For cyclic data (graphs, doubly-linked lists), use std/arena. Nodes reference each other via Handle<T> — typed indices — instead of pointers:
milo
from "std/arena" import { Arena, Handle, arenaNew, arenaAlloc, arenaModify }
struct DLNode {
value: i64,
prev: Option<Handle<DLNode>>,
next: Option<Handle<DLNode>>,
}
fn main(): i32 {
var arena: Arena<DLNode> = arenaNew()
let a = arenaAlloc(arena, DLNode { value: 1, prev: Option.None, next: Option.None })
let b = arenaAlloc(arena, DLNode { value: 2, prev: Option.Some(a), next: Option.None })
arenaModify(arena, a, (n: DLNode) => {
var updated = n
updated.next = Option.Some(b)
return updated
})
return 0
}