LEARN RYFT

Modules & packages

Public exports, namespaces and content-verified local dependencies.

Use namespaced imports to keep library APIs explicit. Local path dependencies are supported; a public registry and remote package installation are not implemented.

Project layout

my-service/
  ryft.toml
  main.rz
  src/
    math.rz
[project]
name = "my-service"
version = "0.1.0"
entry = "main.rz"

The CLI reads project.entry when no source is passed from the manifest’s directory. Project name and version describe your project; they do not select a compiler release or publish a package. Entries must remain inside the project root.

Exports and namespaced imports

In src/math.rz:

fn multiplier() -> i64 { return 2; }
pub fn double(value: i64) -> i64 { return value * multiplier(); }
pub struct Point { x: i64; y: i64; }

In main.rz:

import "src/math.rz" as math;
fn main() {
    let point = math::Point { x: 20, y: 22 };
    println(math::double(point.x));
}

Private helpers are callable within their module; math::multiplier() is rejected outside it. Export declarations with pub fn, pub struct and pub enum. pub impl exports methods, and public imports can reexport nested namespaces. Public APIs cannot expose private types. HTTP apps cannot be imported as aliased libraries.

Imports are resolved relative to the importing file. Import cycles are rejected. Importing one module under different aliases is supported. Legacy import "file.rz"; merges declarations into the shared project namespace and does not provide the alias visibility boundary; prefer aliases for new libraries.

Local dependencies

Add a sibling library to ryft.toml:

[dependencies]
common = { path = "../common" }

Then import a file from its declared root:

import "@common/math.rz" as math;

From the project directory:

ryft lock
ryft check
ryft build -o service.exe

ryft.lock records SHA-256 content hashes for dependency .rz files and manifests. Checks/builds reject missing or stale locks when dependencies are declared. Review a dependency change before refreshing the lock, then commit the manifest and lock with your application source.

Dependency source is local and must exist on the build machine. The lock is an integrity check, not a downloader, version resolver, trust signature or sandbox. Symlinks are rejected during dependency hashing. The compiler limits source count, nesting and aggregate size.

Ryft 0.3.0Source: docs/modules-and-packages.md

Search installation, types, routes, storage and more.