Skip to content

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 project
let 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

Terminal window
# Install the CLI
cargo install cargo-rusta
# Scaffold a new project
cargo rusta new my-api
cd my-api
# Run it
cargo run

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

CratePurposeStatus
rustaCore framework: routing, DI, middleware✅ Stable
rusta-apmDistributed tracing, spans, transactions✅ Stable
rusta-loggerStructured logging with context propagation✅ Stable
rusta-diStandalone DI container✅ Stable
rusta-macrosProc-macros for #[controller], #[injectable]✅ Stable

Next Steps