Gossamer standard library¶
One page per module. Source is crates/gossamer-std/src/; this index is regenerated from manifest::ALL_MODULES by gos doc --emit-stdlib.
For receiver methods on built-in types, see Methods by type.
| Module | Summary |
|---|---|
std::archive::tar |
Unix tar reader and writer (USTAR / PAX-aware decode). |
std::archive::zip |
ZIP archive reader and writer. |
std::bufio |
Buffered readers, writers, and line scanners. |
std::bytes |
Byte buffers, builders, and slice helpers. |
std::collections |
Built-in container types. |
std::compress::bzip2 |
bzip2 encoder / decoder (BZh format). |
std::compress::flate |
Raw DEFLATE (RFC 1951) encoder / decoder. |
std::compress::gzip |
gzip encoder / decoder (RFC 1952; flate2-backed). |
std::compress::zlib |
zlib (RFC 1950) encoder / decoder. |
std::compress::zstd |
Zstandard encoder / decoder (RFC 8478; libzstd-vendored). |
std::context |
Request-scoped cancellation, deadlines, and timeouts. |
std::crypto::aead |
Authenticated encryption with associated data. |
std::crypto::blake3 |
BLAKE3 hashing. |
std::crypto::ecdsa |
ECDSA over the NIST P-256 curve. |
std::crypto::ed25519 |
Ed25519 digital signatures. |
std::crypto::hmac |
HMAC-SHA-256 keyed MACs. |
std::crypto::insecure |
Legacy / broken hashes (MD5, SHA-1). Compat only - never use for new code. |
std::crypto::kdf |
Password-based key-derivation functions. |
std::crypto::password |
Argon2id password hashing facade: PHC-string hash / verify / re-hash policy. |
std::crypto::rand |
Secure random bytes from the host CSPRNG. |
std::crypto::sha256 |
SHA-256 hashing. |
std::crypto::sha512 |
SHA-512 hashing. |
std::crypto::subtle |
Constant-time comparison helpers. |
std::crypto::x509 |
X.509 certificate parsing. |
std::database::sql |
Driver-pluggable SQL database access. No driver ships in the box; bring your own (Postgres, MySQL, SQLite, ...) by registering one at startup. |
std::encoding::ascii85 |
ASCII85 / base85 encode / decode. |
std::encoding::base32 |
RFC 4648 base32 (uppercase) encode / decode. |
std::encoding::base64 |
RFC 4648 base64 encode/decode. |
std::encoding::binary |
Big/little-endian integer packing and varint codecs. |
std::encoding::csv |
CSV record reader and writer. |
std::encoding::hex |
Lowercase hex encode/decode. |
std::encoding::json |
JSON parser, emitter, and derive support. |
std::encoding::pem |
PEM block encoder and decoder. |
std::encoding::toml |
TOML 1.0 parsing + emission. Pair with the turbofish from_toml::<Type> for typed decoding (struct auto-derive). |
std::encoding::xml |
Streaming XML decoder + builder (quick-xml). |
std::encoding::yaml |
YAML 1.2 parser/emitter (serde_norway-backed). |
std::env |
Process environment, command-line arguments, working directory. |
std::errors |
Error construction, wrapping, and chain traversal. |
std::flag |
Batteries-included CLI argument parsing. |
std::fmt |
Formatted printing and string interpolation. |
std::fs |
Filesystem reading, writing, and traversal (Rust std::fs shape). |
std::hash::adler32 |
Adler-32 checksums. |
std::hash::crc32 |
CRC-32 (IEEE) checksums. |
std::hash::fnv |
FNV-1a non-cryptographic hash (32-bit, 64-bit). |
std::html |
HTML text escaping and unescaping. |
std::html::template |
Context-aware HTML templates with auto-escape (text/attr/URL/JS). The context classifier is heuristic - sound for typical server-rendered responses but NOT a content-security-policy substitute; sanitize untrusted HTML fragments with a dedicated sanitizer. |
std::http |
HTTP/1.1 and HTTP/2 client and server. HTTP/2 negotiates via ALPN over TLS automatically (Go-style); h2c entry points are explicit. Write a handler as a cohort and an arena: cohort { } joins or cancels every goroutine the request spawned before the response is written, and its first child failure becomes the block's Err for the handler to turn into a status; arena { } bump-allocates what the request builds and frees it wholesale on every exit path, with escape checked at compile time. Dependency injection is closure capture - build the router from closures capturing the pool and the configuration. |
std::http::chunked |
RFC 7230 ยง4.1 chunked transfer-encoding reader and writer. |
std::http::cookie |
RFC 6265 cookie parser and Set-Cookie builder. |
std::http::csrf |
Double-submit-cookie CSRF protection with Origin / Referer allowlist. |
std::http::form |
application/x-www-form-urlencoded parser and builder. |
std::http::health |
Liveness and readiness endpoints are ordinary handlers over std::lifecycle: answer 200 from a liveness route, and 200/503 from lifecycle::is_ready() on a readiness route, which drops to false on its own when shutdown begins. A probe registry with per-check timeouts belongs in an application package. |
std::http::middleware |
Composable middleware: request_id, cors, security_headers, hsts, cache_control, etag, rate_limit, body_limit, timeout, compress_gzip, logger, recoverer, basic_auth, bearer_auth, safe_defaults. |
std::http::multipart |
RFC 7578 multipart/form-data streaming parser. |
std::http::native_client |
Goroutine-driven HTTP/1.1 client over std::net (no ureq, no blocking pool). |
std::http::proxy |
Reverse proxy on top of http::Client. Director-style request mutator + hop-by-hop strip + error handler. |
std::http::query |
A request's query string is already parsed: read request.query for the raw text and request.query_pairs for the decoded name/value pairs. |
std::http::router |
Go 1.22-class ServeMux: method-aware path patterns with parameter captures + prefix routes. |
std::http::session |
Signs and verifies a session payload. The cookie itself - name, attributes, expiry, a server-side store, id rotation on privilege change, revocation - is application policy and belongs in a session package built on these two. |
std::http::sse |
Server-Sent Events (text/event-stream) emitter with heartbeat ticks and retry hint. |
std::http::state |
Dependency injection is closure capture: build the router from closures that capture the pool, the cache, and the configuration, and each handler reads what it captured. A captured heap value is shared, so one map serves every request. |
std::http::static_files |
Caching static-file handler: ETag, Last-Modified, byte ranges, MIME sniff. |
std::http::websocket |
RFC 6455 WebSocket support. Server-side accept + send_text / send_binary / ping / pong / close. |
std::http_h3 |
HTTP/3 over QUIC. std::http_h3 is the retained 0.27 spelling; no std::http::h3 alias. |
std::httptest |
Fixtures for testing HTTP code. A handler is a function from a request to a response, so record calls one in memory; a test that is about the wire builds an http::Server, binds port 0, and reads the address back. |
std::image |
Opaque RGBA8 image handles with PNG and JPEG codecs. |
std::io |
Stream-oriented I/O abstractions and process standard streams. |
std::iter |
Sequence adapters: map, filter, fold, zip, enumerate, chain, etc. A Vec argument is traversed eagerly; an Iterator argument keeps the adapter lazy and answers with another iterator. |
std::jwt |
RFC 7519 tokens. Signs with HS256 / HS384 / HS512, ES256, and EdDSA; verifies those plus the RS256 / RS384 / RS512 family every mainstream identity provider mints with. Claims cross the boundary as JSON text. |
std::lifecycle |
Process readiness and graceful shutdown, with systemd sd_notify. Shutdown is observed, not dispatched: wait for it, then drain with ordinary statements - spawn(|| serve()), lifecycle::ready(), lifecycle::await_shutdown(), then the cleanup. |
std::math |
Mathematical constants and f64 functions (Go's math package shape). |
std::math::big |
Arbitrary-precision integers (num-bigint). |
std::math::bits |
Integer bit-manipulation operations (Go's math/bits shape). |
std::math::rand |
Deterministic pseudo-random number generation. |
std::metrics |
Prometheus-compatible primitives (Counter, Gauge, Histogram) and a Registry rendering the standard text-exposition format. |
std::mime |
RFC 2045 media type parsing, parameter extraction, and extension lookup. |
std::net |
TCP/UDP networking primitives. |
std::net::ip |
String-level IPv4 / IPv6 parsing and classification helpers. |
std::net::netip |
Typed IP-address parsing, classification, and addr:port helpers (Go's net/netip shape). |
std::net::smtp |
Sends one message per call, so an application can mail a password reset, an address verification, a magic link, or a security notice. A pool, a queue, retries, and bounce handling are application policy and belong in a package built on these. Port 465 speaks TLS from the first byte; any other port starts in the clear and upgrades through STARTTLS when the server offers it, and credentials are refused rather than sent to a server offering no encryption. |
std::net::url |
Network URL parsing and component escaping; never use filesystem-path rules. |
std::option |
Data-last Option combinators for pipeline chaining: map, filter, unwrap_or, and_then, etc. |
std::os |
Operating-system identity. |
std::os::exec |
Deprecated compatibility facade for child processes; new code uses std::process. |
std::os::signal |
POSIX-style signal subscription (Go's os/signal shape). |
std::os::user |
POSIX user / group lookup. Unix-backed by nix; Windows falls back to env vars. |
std::panic |
Panic / catch_unwind integration. |
std::path |
Lexical filesystem-path operations; platform path grammar, no URL parsing. |
std::pprof |
Runtime profiles in the text format go tool pprof reads, plus a Chrome-trace scheduler capture. |
std::process |
Canonical process control and child-process API; std::os::exec is compatibility-only. |
std::regex |
Compiled regular expressions (Rust regex crate syntax; no backreferences or look-around). |
std::result |
Data-last Result combinators for pipeline chaining: map, map_err, unwrap_or_else, etc. |
std::runtime |
Goroutine / scheduler introspection and tuning. |
std::slog |
Structured, levelled logging. |
std::sort |
Explicit stable ordering and sorted-sequence search, the deliberate counterpart to Vec's unstable inherent sort. |
std::strconv |
Conversions between strings and primitive numeric types. |
std::strings |
String operations. |
std::sync |
Synchronisation primitives beyond channels. |
std::testing |
Assertions and sub-test harness helpers. |
std::thread |
OS-thread scheduling hints and CPU introspection; user concurrency uses goroutines, not thread spawning. |
std::time |
Wall-clock and monotonic time facilities. |
std::tls |
Rustls-backed TLS support exposed through http::serve_tls and net::TcpStream TLS upgrades. The configuration constructors are host-runtime internals, not Gossamer callables. |
std::trace |
W3C trace-context-compatible distributed tracing. Identifier types, request-scoped SpanContext, process-level Tracer, and OTLP JSON export. |
std::unicode |
Unicode general-category predicates, casing, normalization, and segmentation. |
std::utf16 |
UTF-16 encoding/decoding and surrogate pair helpers. |
std::utf8 |
UTF-8 validation and scalar decoding. |
std::uuid |
UUID v4 (random) and v7 (timestamp-ordered) generation, parse, and normalize. |
std::validate |
Trait-based field validation: implement Validate, collect FieldErrors into Errors. |