Cargo.toml, Sifr reads the resolved package graph via cargo metadata and constructs its own Sifr package graph on top of it. This means the full power of Cargo’s ecosystem — version ranges, Git sources, path dependencies, private registries — is available to every Sifr project without Sifr having to reimplement a resolver.
Declaring dependencies
Add dependencies toCargo.toml exactly as you would in any Rust project. Runtime dependencies go in [dependencies]; dependencies used only for tests or development tooling go in [dev-dependencies].
Normal
sifr run, sifr check, sifr package, and sifr publish commands only expose runtime [dependencies] as import roots. Dev dependencies are available only in test contexts. Use sifr tree --edges dev if you want to inspect the dev dependency graph explicitly.Fetching dependencies with sifr fetch
After adding or changing a dependency, run sifr fetch to resolve and download it:
--locked to prevent the lockfile from being updated:
sifr fetch delegates to Cargo under the hood and forwards your lock and network flags automatically through the package session.
Inspecting the dependency tree with sifr tree
Visualize your full dependency graph with sifr tree:
--workspace if needed.
Lock modes
Sifr passes lock and network semantics directly to Cargo. Use these flags consistently across all package commands for reproducible results.| Flag | Effect |
|---|---|
--locked | Cargo rejects any lockfile updates. Fails if the lockfile is out of date. |
--offline | Cargo does not access the network. All required package sources must already be cached locally. |
--frozen | Combines --locked and --offline. No lockfile updates and no network access. |
Pure Sifr packages
A pure Sifr package contains no non-trivial Rust code — all behavior is expressed in.sifr files. Because Cargo requires at least one build target, Sifr generates a minimal marker file at src/lib.rs:
src/lib.rs but does not declare Rust-backed behavior. Do not add Rust logic to lib.rs in a pure Sifr package.
Trust policy for backend Rust crates
Some Sifr packages interoperate with Rust crates at the backend level. Sifr enforces a trust policy that controls which Rust crates a package is permitted to call. This policy is configured insifr.toml and validated during sifr package and sifr publish.
Packages that exceed their declared trust boundary are rejected at publish time with a backend trust violation error.
Cross-package imports and public APIs
Only names that a dependency exposes through its public namespace are importable from outside that package. A package’s public API is defined bysrc/__init__.sifr and any child namespaces that have their own __init__.sifr. Implementation files such as src/client.sifr are private to the package unless explicitly re-exported.
Keeping Cargo.toml in sync with sifr repair
After manual edits to Cargo.toml or after a merge conflict, the Sifr-managed entries in Cargo.toml may drift from the expected state. Check for drift without making any changes:
Cargo.toml entries and restore a missing pure marker: