5 releases
| 0.1.71 | Jan 17, 2026 |
|---|---|
| 0.1.70 | Jan 17, 2026 |
| 0.1.69 | Jan 17, 2026 |
| 0.1.68 | Jan 17, 2026 |
| 0.1.67 | Jan 16, 2026 |
#2007 in Procedural macros
Used in ferro-rs
100KB
2K
SLoC
ferro-macros
Procedural macros for the Ferro framework.
Macros
#[handler]
Transform functions into HTTP handlers with automatic parameter extraction:
use ferro::{handler, Request, Response};
#[handler]
pub async fn show(req: Request, id: i64) -> Response {
// id is extracted from path parameter
Ok(json!({"id": id}))
}
#[request]
Define validated request data:
use ferro::request;
#[request]
pub struct CreateUserRequest {
#[validate(email)]
pub email: String,
#[validate(length(min = 8))]
pub password: String,
}
#[service]
Mark traits for dependency injection:
use ferro::service;
#[service]
pub trait UserService: Send + Sync {
async fn find(&self, id: i64) -> Option<User>;
}
#[injectable]
Auto-register implementations as singletons:
use ferro::injectable;
#[injectable]
pub struct AppState {
pub counter: u32,
}
#[domain_error]
Define domain errors with HTTP response conversion:
use ferro::domain_error;
#[domain_error(status = 404, message = "User not found")]
pub struct UserNotFoundError {
pub user_id: i64,
}
inertia_response!
Create Inertia.js responses with compile-time component validation:
use ferro::inertia_response;
inertia_response!("Users/Index", UsersProps { users })
describe! and test!
Jest-like testing macros:
use ferro::{describe, test, expect};
describe!("UserService", {
test!("finds user by id", async fn(db: TestDatabase) {
let user = UserService::find(1).await;
expect!(user).to_be_some();
});
});
License
MIT
Dependencies
~2.3–4MB
~74K SLoC