Skip to content
Kavachकवच

Standard Library

● Intermediate4 minSpec 14

Every standard-library module, with a page each: its types, methods and functions, their definitions and examples, and the files that declare them.

A module is used with use std.name. Some parts are built into the compiler and runtime; the rest is written in Kavach, in stdlib/, with contracts and examples like any other code.

ModuleSpecWritten in Kavach
std.fs14.3fs.kav: the FsError union file operations fail with, FileInfo, and FileWriter, a file written piece by piece (spec 14.3)
std.time14.4digits.kav: the digits and offsets of times as text; time.kav: Duration (5.seconds), Date, Time, DateTime, Weekday; clocks, sleeping and intervals come from the runtime (spec 14.4)
std.math14.5math.kav: gcd, lcm, factorial, is_prime, mean
std.io and std.cli14.6cli.kav: StopHold and cli.on_stop(grace), a hold on the program's stop (spec 5.8, decision 0088); arguments, exit and parse are built into the compiler and runtime (spec 14.6)
std.test14.7test.kav: Sample, for types that make their own generated values, and Gen, the seeded choices they make them from (spec 14.7); the numbers come from the runtime
std.regex14.8Nothing: the compiler and runtime give it all
std.text and std.collections14.9text.kav: padding, words, capitalizing, truncating, blank textcollections.kav: chunks, zip, unique items, counting, flattening
std.random14.15random.kav: whole numbers in a range, floats, picks, shuffles and bytes, from the operating system's secure generator, seeded under kavach test (spec 14.15)
std.log14.12log.kav: log events are records the program defines; levels and the console sink, written in Kavach (spec 14.12)
std.term14.13term.kav: colors and styles for the terminal, off when output is not a terminal; progress bars; prompts (spec 14.13)
std.crypto14.19crypto.kav: the CryptoError union; hashes, HMAC, passwords (Argon2id), signatures and AES-GCM come from ring and argon2 in the runtime (spec 14.19, decision 0093)
std.base6414.20base64.kav: the Base64Error union; encoding and decoding are built into the runtime (runtime/core/src/base64.rs, spec 14.20)
std.compress14.21compress.kav: Format, its levels and names, CompressError, and encode/decode over the runtime's encode_bytes/decode_bytes (runtime/core/src/compress.rs, spec 14.21)
std.json2.12json.kav: the Json and JsonError types and reading a Json, written in Kavach; every program has them. Parsing and writing are in the compiler and runtime (spec 2.12)
std.tasks9.4tasks.kav: Taken<T>, what a channel's take() gives (spec 9.4, decision 0097); every program that uses a channel gets it, and tasks and channels themselves are built in
std.net14.10net.kav: the NetError union and the ClientCert record; TCP, UDP and QUIC come from the runtime (spec 14.10). HTTP is in http/
std.http14.11http.kav: HTTP/1.1 and HTTP/2 clients and servers, and HTTP/3 clients, on std.net, written in Kavach, with typed JSON calls and sessions that keep a connection open (spec 14.11); server.kav: the server http.serve runs, each client held to its ServeLimits (decision 0087); multipart.kav: forms read part by part (http.form, decision 0090); upgrade.kav: WebSockets and server-sent events (decision 0092); message.kav: reading HTTP/1.1 messages, chunked bodies too, and where each ends; h2.kav: HTTP/2 requests and responses, whole or piece by piece; h2wire.kav: its frames, streams and flow control; hpack.kav: HTTP/2 header compression; h3.kav: HTTP/3 requests over QUIC, with QPACK (decision 0022)
std.grpc14.14grpc.kav: gRPC clients and servers from Kavach types; frames.kav: message prefixes and status trailers; protobuf.kav: Protocol Buffers from a type's JSON Schema, written in Kavach on std.http.h2 (spec 14.14, decision 0027)
std.ai8.4ai.kav: AiError, what ask<T> fails with, and Model, the model and settings (effort, tokens, thinking, instructions, stop text, timeout, retries, address and key, extra request fields) an ask uses; the model call is in the runtime (spec 8.4)
std.agents14.16agents.kav: ApprovalRequest, ApprovalError, and waiting and answer, which answer agents' approval requests in code, behind Approvals; the requests are found and answered by the runtime, as is call_key (spec 14.16)
std.clipboard14.17clipboard.kav: the ClipboardError union; reading and writing the clipboard come from the runtime, behind Clipboard (spec 14.17)
std.devices14.18devices.kav: SerialPort, its methods, and DeviceError; ports are opened, read and written by the runtime, behind Serial (spec 14.18)
std.window14.22window.kav: AppWindow and its methods, Event, WindowError, over the runtime's windows by number (runtime/window, spec 14.22, decision 0104)
std.process14.23process.kav: Child and its methods, Output, Exit, Finished, ProcessError, and run/start over the runtime's children by number (runtime/process, spec 14.23, decision 0105)
std.gpu14.24gpu.kav: Screen, Frame and GpuError, drawing into a window over the runtime's screens and frames by number (runtime/gpu/src/draw.rs, spec 14.24, decision 0106)
std.literals10.15literals.kav: LiteralProblem, what a tag's checker gives for a tagged literal (spec 10.15, decision 0100)
stdlib/README.md

One page for each form