playbook/antigravity-awesome-skills/skills/ecl-harness-engineer/references/adapters/rust.md

6.5 KiB

adapter
language display_name version detection commands package_manager route_detection import_analysis layer_conventions dependency_detection linter naming ci
rust Rust 1.0
files content_patterns confidence
Cargo.toml
Cargo.lock
file pattern
Cargo.toml \[package\]
0.95
build test lint lint_arch format start dev
cargo build cargo test cargo clippy -- -D warnings null cargo fmt cargo run cargo watch -x run
detection default install_command
cargo cargo build
server_indicators cli_indicators frontend_indicators patterns
pattern description frameworks
use actix_web|actix_web:: Actix-web framework
actix-web
pattern description frameworks
use axum|axum:: Axum web framework
axum
pattern description frameworks
use rocket|#[rocket::main] Rocket web framework
rocket
pattern description frameworks
use warp|warp:: Warp web framework
warp
pattern description frameworks
use hyper|hyper:: Hyper HTTP library
hyper
pattern description frameworks
use tide|tide:: Tide web framework
tide
pattern description frameworks
use clap|clap:: Clap CLI framework
clap
pattern description frameworks
use structopt|structopt:: StructOpt CLI (legacy clap)
structopt
pattern description frameworks
std::env::args Standard library args parsing
stdlib
pattern description frameworks
use leptos|leptos:: Leptos WASM framework
leptos
pattern description frameworks
use yew|yew:: Yew WASM framework
yew
pattern description frameworks
use dioxus|dioxus:: Dioxus UI framework
dioxus
type regex groups frameworks
route #[(?:web::)?(get|post|put|delete|patch)\s*(\s*"([^"]+)"
method
path
actix-web
type regex groups frameworks
route .(get|post|put|delete|patch)\s*(\s*"([^"]+)"
method
path
axum
type regex groups frameworks
route #[(get|post|put|delete|patch)\s*(\s*"([^"]+)"
method
path
rocket
type regex groups frameworks
command #[command\s*(.*name\s*=\s*"([^"]+)"
command_name
clap
type regex groups frameworks
command Command::new\s*(\s*"([^"]+)"
command_name
clap
list_packages import_pattern source_extensions module_root_file
cargo metadata --format-version 1 use\s+([\w:]+)
.rs
Cargo.toml
patterns
layer paths description
0
src/models
src/types
src/domain
Domain types and models
layer paths description
1
src/utils
src/common
src/lib.rs
Shared utilities
layer paths description
2
src/services
src/core
src/repository
Business logic
layer paths description
3
src/handlers
src/routes
src/api
HTTP/API handlers
layer paths description
4
src/main.rs
src/bin
Entry points
manifest_file databases services env_var_patterns
Cargo.toml
pattern type default_port
sqlx.*postgres|tokio-postgres|diesel.*postgres postgres 5432
pattern type default_port
sqlx.*mysql|diesel.*mysql mysql 3306
pattern type default_port
mongodb mongodb 27017
pattern type default_port
redis|deadpool-redis redis 6379
pattern type default_port
rusqlite|sqlx.*sqlite sqlite 0
pattern type default_port
rdkafka|kafka kafka 9092
pattern type default_port
lapin|amqp rabbitmq 5672
pattern type default_port
elasticsearch elasticsearch 9200
pattern
std::env::var(\s*"([^"]+)"
pattern
env::var(\s*"([^"]+)"
pattern
dotenv::var(\s*"([^"]+)"
template_section script_extension run_command
rust-linter .rs cargo clippy
file_pattern test_pattern directory_style
^[a-z][a-z0-9_]*.rs$ ^[a-z][a-z0-9_]*.rs$ snake_case
github_actions
image setup_steps cache_paths
null
uses: dtolnay/rust-toolchain@stable with: components: clippy, rustfmt
~/.cargo/registry
~/.cargo/git
target

Rust Adapter

Architecture Note

Rust's module system (mod, pub, pub(crate)) naturally enforces encapsulation. The lint_arch command is null because Rust's compiler already prevents many dependency violations at compile time. However, a custom architectural linter can still be valuable for enforcing higher-level layer boundaries.

Server Start Command Inference

  1. Existing harness/config/environment.json startup command, if present
  2. Cargo.toml has [[bin]] section → cargo run --bin <name>
  3. Default → cargo run

For release builds: cargo build --release && ./target/release/<name>

Framework-Specific Notes

Axum

  • Router-based: Router::new().route("/path", get(handler))
  • Extractors for request parsing: Json<T>, Path<T>, Query<T>
  • State sharing via Extension or State
  • Default: runs on 0.0.0.0:3000

Actix-web

  • Attribute macros: #[get("/path")], #[post("/path")]
  • App factory pattern: App::new().service(handler)
  • Default: HttpServer::new(...).bind("127.0.0.1:8080")

Rocket

  • Attribute macros: #[get("/path")], #[post("/path")]
  • Fairings for middleware
  • Config via Rocket.toml

Testing Patterns

  • Unit tests: inline #[cfg(test)] mod tests { ... } in same file
  • Integration tests: tests/ directory at crate root
  • cargo test runs both
  • Useful flags: cargo test -- --nocapture (show println output)

Workspace Support

If [workspace] in root Cargo.toml:

  • Each member crate may have its own layer conventions
  • Build: cargo build --workspace
  • Test: cargo test --workspace