Expand description
§ActorEntity Trait
The ActorEntity trait defines the contract that every resource (User, Product, Order, …) must implement to be managed by the generic ResourceActor. It specifies associated types for IDs, DTOs, actions, context, and errors, and provides lifecycle hooks (on_create, on_update, on_delete, handle_action). Implementing this trait enables the framework to offer a uniform CRUD + Action API for any domain model.
Trait that any resource entity must implement to be managed by ResourceActor.
§Architecture Note
Why do we need this trait?
By defining a contract (ActorEntity) that all our resource types (User, Product, Order)
must satisfy, we can write the ResourceActor logic once and reuse it everywhere.
This is “Polymorphism” in action.
We use “Associated Types” (type Id, type Create, etc.) to enforce type safety.
A User entity requires a UserCreate payload, and you can’t accidentally send it
a ProductCreate payload. The compiler prevents this class of bugs entirely.
§Provided Methods (Hooks)
This trait includes Provided Methods (methods with default implementations) for lifecycle hooks:
You do not need to implement these methods unless you want to customize behavior.
The default implementation does nothing (Ok(())).
Traits§
- Actor
Entity - Trait that any resource entity must implement to be managed by ResourceActor.