Build Modern Rust APIs
A clean-architecture framework with dependency injection, declarative routing, and built-in observability.
Clean Architecture
Controller → Service → Repository layers with clear separation of concerns
Declarative Routing
`#[controller]`, `#[get]`, `#[post]` — routes register themselves
Built-in Observability
APM tracing and structured logging — opt-in, zero-config
Quick Comparison
// Raw Axum — boilerplate you write every projectlet app = Router::new() .route("/users", get(list_users).post(create_user)) .layer(Extension(Arc::new(UserService::new()))) .layer(CorsLayer::permissive());
// Rusta — declare intent, framework handles wiring#[controller("/users")]impl UserController { #[get("/")] async fn list(&self) -> Response { Http::json(self.svc.list().await) }
#[post("/")] async fn create(&self, Json(body): Json<CreateUserDto>) -> Response { Http::created(self.svc.create(body).await) }}Quick Start
# Install the CLIcargo install cargo-rusta
# Scaffold a new projectcargo rusta new my-apicd my-api
# Run itcargo runOr add Rusta to an existing project — see the Installation guide.
Quick Example
use rusta::prelude::*;use std::sync::Arc;
#[controller("/users")]impl UserController { #[get("/")] pub async fn list(&self) -> Response { Http::json(self.svc.find_all().await) }
#[post("/")] pub async fn create(&self, Json(body): Json<CreateUserDto>) -> Response { Http::created(self.svc.create(body).await) }}
#[tokio::main]async fn main() { let mut container = Container::new(); container.register(UserService::construct(&container)); App::new().container(container).run("0.0.0.0:3000", |res| match res { Ok(addr) => println!("Started on {}", addr), Err(msg) => eprintln!("Startup error: {}", msg), }).await;}Ecosystem
Rusta is a family of crates — use what you need, skip what you don’t.
| Crate | Purpose | Status |
|---|---|---|
rusta | Core framework: routing, DI, middleware | ✅ Stable |
rusta-apm | Distributed tracing, spans, transactions | ✅ Stable |
rusta-logger | Structured logging with context propagation | ✅ Stable |
rusta-di | Standalone DI container | ✅ Stable |
rusta-macros | Proc-macros for #[controller], #[injectable] | ✅ Stable |
Next Steps
- New to Rusta? → Installation → Quick Start
- Coming from Axum? → Controllers Guide → Dependency Injection
- Building for production? → Error Handling → Testing → Deployment