The Zuri Standard Library Zuri

The Zuri Standard Library

Every module Zuri ships with, and every public name in each one. The pages here are generated from the library's own doc blocks, so what you read is what the code says.

This is a reference, not a tutorial. It answers "what does this take and what does it return". For the narrative version, with worked examples and the reasoning behind the design, read The Zuri Programming Language, which cargo run-docs serves alongside this.

How to Read a Page

Every module page opens with the import that reaches it, then the module's own description, then its members. A package also carries an index of its whole public surface, because a name reached through a package may well be declared in a file called something else.

Signatures are written the way the source declares them:

  • name: string is a parameter that must be a string, enforced at the call.
  • name: ?string accepts a string or nil, which is how an optional argument is spelled.
  • ...values takes any number of arguments and arrives as a list.
  • -> string is what the call gives back.

A name beginning with an underscore is private: the compiler refuses to import it across a module boundary, so none appear here.

The Modules

Text and Markup

Parsing, building and colouring text meant to be read.

Module What it is for
html An HTML5 parser, DOM and serializer, following the WHATWG HTML Living Standard.
markdown Converts Markdown to HTML.
wire Wire, an HTML template engine.
url Parses, builds, resolves and processes URLs, and URL-like identifiers such as mailto: and tel: links, as defined in [RFC...
mime Detects the MIME type of a file, either from its name or from the first bytes of its contents.
colors Converts and manipulates colors, and writes colored text to the terminal.

Data Formats

Reading and writing the formats other programs speak.

Module What it is for
json Encodes and decodes JSON.
yaml Parses and writes YAML documents, following YAML 1.2.2.
toml Reads TOML for its values, or edits it in place without disturbing the rest of the file.
csv Reads and writes CSV (comma-separated values) data, following RFC 4180.
base64 Encodes binary data as text, and decodes it again, using the base64 encoding defined in [RFC...
struct Converts between Zuri values and the binary layout of C, C++ and Rust structs.

Numbers and Collections

Arithmetic, and the containers the built-in types do not cover.

Module What it is for
math Mathematical functions, trigonometric and otherwise, and common mathematical and scientific constants such as PI.
array Typed arrays with fixed-width elements: two's complement integers, from Int8Array and UInt8Array up to Int64Array and...
set Sets, in the mathematical sense.

Dates and Times

Calendar arithmetic, formatting, and the timezone database.

Module What it is for
date Dates and times, including calendar dates and Julian dates.

The Machine

The filesystem, other processes, the terminal, the command line, and the configuration around them.

Module What it is for
os Zuri's interface to the operating system: environment variables, the filesystem, other processes and the machine itself.
env Reads configuration from a file into the environment, and reads it back in the types your program uses.
io Streams, terminals, and the operating system's standard input, output and error streams.
args A framework for building command-line interfaces.
log Logging for Zuri applications and modules.
stat Constants and functions for interpreting the results of file.stats().

Testing

Suites, matchers, test doubles, snapshots, and the reports they produce.

Module What it is for
test A testing framework with suites, assertions, mocks, snapshots, setup and teardown hooks, and readable reports.

Networking

Sockets, addresses, and a complete HTTP stack and JSON-RPC on top of them.

Module What it is for
net Networking: TCP and UDP sockets, Unix domain sockets, and IP addresses.
http A complete HTTP stack, with a client, a server and the building blocks they share.
rpc JSON-RPC 2.0, for calling methods in another program and answering its calls, over HTTP, WebSockets, sockets, pipes or any stream...

Security and Identity

Hashing, signing, password storage, tokens and input validation.

Module What it is for
crypto Cryptographic primitives for Zuri programs.
hash Cryptographic and non-cryptographic hash functions, and HMAC.
bcrypt Creates and verifies bcrypt password hashes, and reads the cost factor and salt from an existing hash.
jwt JSON Web Tokens (JWT), as defined in RFC 7519.
uuid Generates, parses, validates and inspects UUIDs (universally unique identifiers), as defined in RFC 9562 and RFC 4122.
validate Validates input against a schema of rules.

Compression and Archives

Every codec and container format the runtime ships with.

Module What it is for
compress Compression and decompression with several algorithms, both in memory and as a stream, and reading and writing TAR and ZIP...

Concurrency

Real OS threads, with separate heaps and message passing between them.

Module What it is for
isolate Runs code in parallel on a pool of operating system threads.

Images

Decoding, drawing, filtering and encoding raster images.

Module What it is for
imagine Reads, writes, draws on and transforms raster images.

Databases

One contract every relational database answers, the adapters that answer it, and the schema changes, migrations and models built on top.

Module What it is for
sql A single interface for relational databases, whichever one you use.

Mail

Messages, the three protocols that move them, and the servers at the far end.

Module What it is for
mail Email, from building messages to sending and receiving them.

Interoperability

Calling C and Rust libraries, being called back by them, and linking static ones.

Module What it is for
ffi Calls C and Rust libraries, and lets them call back into Zuri.

Types and Conversion

Checked coercion between types, named constants, and conversions between bases and encodings.

Module What it is for
types Type checking and conversion.
enum Enumerations: a set of unique values, each bound to a symbolic name.
convert Converts data between hexadecimal, numbers in any base, bytes and decimal numbers.

Metaprogramming

Lexing, parsing and compiling Zuri source, and reflecting on live functions, classes and modules.

Module What it is for
zuri Zuri's own compiler pipeline, as a library: lexing, parsing and compiling Zuri source, and a reflect submodule for inspecting...