Skip to content

Native Modules ​

Native modules expose runtime functionality through stable tyrus:* import paths. Their APIs are concise, and their implementations are linked into native binaries. Every module is part of the standard distribution, no package manager, no npm install, no external runtime.

Available Modules ​

ModulePurpose
tyrus:algorithmNative data structures and algorithms for sorting, searching, graphs, trees, and collections.
tyrus:archiveCreate, inspect, and safely extract ZIP, TAR, and TAR.GZ archives.
tyrus:cliInteractive terminal prompt helpers.
tyrus:compressCompress and decompress bytes with Gzip, Deflate, raw Deflate, and Brotli.
tyrus:cryptoCryptographic primitives: digest, HMAC, AES-256-GCM, Argon2, JWT, and secure random.
tyrus:dbVersioned SQLite schema snapshots, read-only schema checks, and the database error contract.
tyrus:encodingExplicit UTF-8, UTF-16, hexadecimal, Base64, Base32, and radix conversion.
tyrus:fsSynchronous file reads and writes for native programs.
tyrus:httpHTTP server, route, response, status, and API-oriented helpers.
tyrus:mathMathematical constants and functions.
tyrus:memoryExplicit ownership, secure erasure, and compile-time layout queries.
tyrus:netAddress parsing, Result-based name resolution, asynchronous TCP and UDP networking, and capability-gated probes.
tyrus:osCross-platform operating system identification: platform, architecture, hostname, locale.
tyrus:processShell-free subprocesses with bounded standard byte streams.
tyrus:simdVectorized addition of equal-length f32[] and f64[] arrays with recoverable Result errors.
tyrus:streamBounded progressive transport with capability-separated reading and writing.
tyrus:taskCooperative async task management: cancellation and timed suspension.
tyrus:temporalNative instants, calendar values, durations, and IANA time zones.
tyrus:testTest suites, assertions, hooks, and modifiers run by tyrus test.
tyrus:utilsNative text helpers such as ANSI styling and FIGlet banners.

Import Style ​

tyrus
import { readFileSync } from "tyrus:fs";
import { HttpStatus } from "tyrus:http";
import { input } from "tyrus:cli";
import { styleText } from "tyrus:utils";
import { digest, hmac, cipher, jwt } from "tyrus:crypto";
import { cancel, sleep } from "tyrus:task";

tyrus:* imports are resolved by the compiler as built-in modules.

Using Modules Together ​

Native modules compose naturally. A typical CLI project might read config from the filesystem, prompt for input, and apply styles:

tyrus
import { writeFileSync, type FsError } from "tyrus:fs";
import { input, confirm } from "tyrus:cli";
import { styleText } from "tyrus:utils";

const main = (): void => {
    const name: string = input({ message: "Project name?" });
    const proceed: boolean = confirm({ message: `Create "${name}"?` });

    if (proceed) {
        match (writeFileSync(`${name}/main.tyr`, `print("hello from ${name}");`)) {
            Ok() => print(styleText("green", `Created ${name}`));
            Err(error) => printError(error.message);
        }
    }
};

Runtime Boundary ​

Native modules should document their public imports, return types, error behavior, and diagnostics before being considered stable. APIs that print terminal UI chrome use stderr so stdout remains reserved for normal program output.