6.5 KiB
6.5 KiB
| adapter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
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
- Existing
harness/config/environment.jsonstartup command, if present Cargo.tomlhas[[bin]]section →cargo run --bin <name>- 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
ExtensionorState - 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 testruns 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