Skip to main content

DomainModel

Trait DomainModel 

Source
pub trait DomainModel { }
Expand description

Marker trait for domain models (business entities).

Domain models represent core business concepts and should:

  • Contain only business-relevant data
  • Be independent of persistence mechanisms
  • Be free of infrastructure dependencies

§Usage

Use the #[domain_model] attribute macro to implement this trait:

#[domain_model]
pub struct Order {
    pub id: Uuid,
    pub customer_id: Uuid,
    pub total: Decimal,
    pub status: OrderStatus,
}

The macro validates field types at expansion time and generates clear error messages if forbidden types (e.g., sqlx::PgPool, http::StatusCode) are detected.

§Thread Safety

This trait does not require Send + Sync. If you need thread-safe domain models, wrap them in Arc<T> at the point of use.

Implementors§