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.

Rust 1.85+MIT

Cargo

cargo add --dev archunit@0.0.2
tests/architecture.rs
use 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.

01

Memory safety and native performance

02

Cargo packages, workspaces, libraries, and services

03

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.

01

Cargo workspace discovery

02

File, layer, and captured-slice policies

03

Rust-native metrics and graph reports

04

PlantUML conformance and export

05

Structured violations and Checkable rules

06

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.

tests/cycles.rs
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.

01

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.
02

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.
03

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.
Read the complete documentation ↗

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.

LanguageRust
Release0.0.2 preview
RuntimeRust 1.85+
LicenseMIT

Where it fits

Put boundaries next to the code they protect.

Common starting points for ArchUnitRust include the following project shapes.

Cargo workspacesCLI toolsRust servicesSystems projects

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 ↗