Skip to main content

Standard Library

The Mux standard library provides cohesive modules for common programming tasks. APIs are explicit, typed, and consistent with Mux's value and resource semantics.

The built-in byte and bytes types are available without an import. byte is one checked octet; bytes is a contiguous mutable byte sequence.

Using the Standard Library​

Import standard library modules using the import keyword:

import_example.mux
Loading...

You can import stdlib in multiple forms:

stdlib_import_forms.mux
Loading...

API style​

Stdlib APIs keep construction and use explicit. new() always returns a default value or builder and never takes configuration arguments; use a named from_* constructor when a value must be created from parts. Mutable handles expose their fields directly, and fallible operations use a typed result or optional. Use use when failure should leave the current function, or inspect the value when local handling is needed:

Mux
Loading...

Serialization and transport stay separate: encode JSON, form data, or text in its owning package, then put the resulting bytes and explicit headers on a general request. There are no verb- or format-specific HTTP helper families. Result and Optional values expose is_ok(), is_err(), is_some(), and is_none() for checked local handling, plus value()/error() extraction after a proven variant. use keeps sequential fallible code flat. Removed APIs are not retained as aliases or compatibility shims; use the current module path and current type directly.

Available Modules​

ModuleDescription
mathMathematical functions and constants
ioByte streams, standard streams, and bounded reader/writer operations
fsFilesystem-oriented file and directory operations
netTCP/UDP primitives plus typed HTTP, SSE framing, and WebSocket bindings
hosted acceptanceRuntime CI contracts for service-backed SQL, native hosts, HTTP/3, and OAuth/OIDC
tlsVerified synchronous TLS client streams
net.urlValidated URLs, components, origins, query pairs, and file URLs
sqlSQL connections, transactions, result sets, and typed SQL values
processExplicit command execution, child handles, captured output, and process metadata
logSynchronous structured logging with replaceable default logger
regexUnicode regular expressions with captures, replacement, and splitting
uuidOpaque UUID values, parsing, formatting, and RFC 9562 generation
cryptoHashing, HMAC, secure random bytes, and authenticated encryption
envEnvironment inspection and mutation (env.get, env.set, env.remove)
data.jsonMutable JSON parsing, conversion, and serialization helpers
data.csvDialect-aware CSV parsing, rendering, streaming, and typed mapping
randomPseudorandom number generation
syncThreads, locks, channels, coordination, and sleep helpers
datetimeTyped calendar values, clocks, parsing, formatting, and durations
dsaData structures and algorithms, including balanced trees and graph algorithms
encodingOne-shot and streaming binary, text, and percent codecs
cliTyped command-line parser builders and returned matches

Contributing​

The standard library is part of the Mux language project. Contributions are welcome! See the Contributing Guide for guidelines.