| Crates.io | ferro-macros |
| lib.rs | ferro-macros |
| version | 0.1.71 |
| created_at | 2026-01-16 17:12:46.31075+00 |
| updated_at | 2026-01-17 20:04:16.197738+00 |
| description | Procedural macros for Ferro framework |
| homepage | |
| repository | https://github.com/albertogferrario/ferro |
| max_upload_size | |
| id | 2048977 |
| size | 102,531 |
Procedural macros for the Ferro framework.
#[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();
});
});
MIT