#[domain_model]Expand description
Marks a struct or enum as a domain model, enforcing DDD boundaries at compile time.
This macro:
- Implements
DomainModelfor the type - Validates at compile-time that fields do not use forbidden infrastructure types
§Usage
ⓘ
// Note: This example requires `modkit` crate which is not available in proc-macro doctest context
use modkit_macros::domain_model;
#[domain_model]
pub struct User {
pub id: i64,
pub email: String,
pub active: bool,
}§Compile-Time Enforcement
If any field uses an infrastructure type (e.g., http::StatusCode, sqlx::Pool),
the code will fail to compile with a clear error message:
ⓘ
use modkit_macros::domain_model;
#[domain_model]
pub struct BadModel {
pub status: http::StatusCode, // ERROR: forbidden crate 'http'
}§Forbidden Types
The macro blocks types from infrastructure crates:
- Database:
sqlx::*,sea_orm::* - HTTP/Web:
http::*,axum::*,hyper::* - External clients:
reqwest::*,tonic::* - File system:
std::fs::*,tokio::fs::* - Database-specific names:
PgPool,MySqlPool,SqlitePool,DatabaseConnection