Cargo workspace discovery
ArchUnitRust
Architecture testing for Rust. Write architecture policies as regular Rust tests. ArchUnitRust discovers the containing Cargo project, analyzes production targets, and provides file, layer, slice, metric, diagram, and graph APIs with explicit failure boundaries.
Cargo
cargo add --dev archunit@0.0.2use archunit::{assert_passes, project_files};
#[test]
fn api_does_not_reach_database() {
let rule = project_files()
.in_path("src/api/**")
.should_not()
.depend_on_files()
.in_path("src/database/**");
assert_passes!(rule);
}Silent product demo
Watch architecture rules run in Rust.
This silent walkthrough follows an ArchUnitRust rule from its Cargo-native test definition to the resulting architecture feedback. Playback starts muted, loops in place, and keeps standard controls available so you can inspect each step.
Watch on YouTube ↗The ecosystem
Rust, in context.
Rust is a compiled systems language focused on memory safety, predictable performance, and fearless concurrency without a garbage collector. Cargo provides a strong package and workspace model, while architecture rules help larger Rust systems keep crate and module boundaries intentional.
Memory safety and native performance
Cargo packages, workspaces, libraries, and services
Strong fit for systems, infrastructure, and CLI software
Adoption snapshot
Public adoption, in context.
crates.io lists ArchUnitRust 0.0.2 with 115 downloads across its published releases. Its recent counter has no comparable date range, so it is not mixed into the 30-day total.
- Package status
- Published on crates.io Public download totals
- Reported history
- 115 All releases through Oct 4, 2026
- Latest 30 days
- Unavailable No comparable 30-day figure
- GitHub stars
- 5 Snapshot of October 4, 2026
Capabilities
What ArchUnitRust brings to the test suite.
The family shares a recognizable architecture vocabulary while each implementation stays honest about its language, toolchain, and maturity.
File, layer, and captured-slice policies
Rust-native metrics and graph reports
PlantUML conformance and export
Structured violations and Checkable rules
Compiled README examples and doctests
Go deeper
Guard every production target in a workspace.
Cargo-native discovery keeps the rule close to the real workspace layout. A single cycle check can cover library and binary targets without teaching a separate tool how the project is built.
use archunit::{assert_passes, project_files};
#[test]
fn production_targets_are_cycle_free() {
let rule = project_files()
.in_path("src/**/*.rs")
.should()
.have_no_cycles();
assert_passes!(rule);
}Documentation highlights
Work with ArchUnitRust beyond the quickstart.
ArchUnitRust follows Cargo workspace and module semantics, then applies the shared ArchUnit vocabulary through Rust-native ownership, immutable builders, and structured results.
Extract Rust-specific dependency evidence
use, pub use, extern crate, mod declarations, and qualified paths are resolved into internal or external graph edges.
- Cargo packages and workspace sources are discovered with project-relative identifiers and memoized extraction.
- Parallel edges keep their import kinds so structural module ownership can be distinguished from executable dependencies.
- Scoped archunit ignore comments omit a known path without suppressing unrelated evidence from the same file.
Write rules as ordinary Rust tests
File, layer, slice, metric, and graph builders produce Checkable values consumed by assertion macros or framework-neutral result handling.
- Cycle rules can exclude mod and pub use edges while retaining a parallel use or path-reference edge.
- Layer policies and slices model architectural ownership above individual modules.
- The library runs its own public rules against its internal modules as executable self-architecture.
Keep evidence deterministic
Offline graph and metrics reports are designed to produce stable artifacts that can be reviewed beside code.
- Check options control exclusions, logging, empty selections, dependency kinds, and cache refresh.
- Typed violations remain data until the assertion or reporting boundary phrases them for a human.
- The Git-based preview is intentionally explicit about its compatibility status and installation source.
Release and compatibility
0.0.2 preview
Published on crates.io as version 0.0.2. The API remains an early pre-1.0 preview while Cargo-native discovery and architecture policies continue to mature.
Where it fits
Put boundaries next to the code they protect.
Common starting points for ArchUnitRust include the following project shapes.
More ecosystems
The same intent, expressed natively.
Explore sibling implementations and carry the architecture vocabulary across a polyglot system.
Make the first boundary executable.
Add one meaningful rule, run it with the existing tests, and grow the architecture suite as the system reveals where it needs protection.
Start with ArchUnitRust ↗