pub enum ResourceRequest<T: ActorEntity> {
Create {
params: T::Create,
respond_to: Response<T::Id>,
},
Get {
id: T::Id,
respond_to: Response<Option<T>>,
},
Update {
id: T::Id,
update: T::Update,
respond_to: Response<T>,
},
Delete {
id: T::Id,
respond_to: Response<()>,
},
Action {
id: T::Id,
action: T::Action,
respond_to: Response<T::ActionResult>,
},
}Expand description
Internal message type sent to the actor to request operations.
§Resource-Oriented Architecture
This enum implements a Resource-Oriented design pattern where each actor manages a specific
type of resource (the ActorEntity). Instead of defining ad-hoc messages for every operation,
we standardize around a set of lifecycle operations that apply to almost any persistent resource.
§The CRUD Pattern
The variants of this enum map directly to standard CRUD (Create, Read, Update, Delete) operations,
plus a custom Action variant for resource-specific logic that doesn’t fit the CRUD model.
- Create: Lifecycle start. Uses
ActorEntity::Createto initialize a new resource. - Get (Read): Retrieval. Fetches the current state of the resource by ID.
- Update: State mutation. Uses
ActorEntity::Updateto modify an existing resource. - Delete: Lifecycle end. Removes the resource.
- Action: Extensibility. Executes a custom
ActorEntity::Action.
§Entity Interaction
This type is generic over T: ActorEntity. It uses the associated types defined in the ActorEntity trait
(like Create, Update, Action) to ensure type safety for every operation.
This guarantees that you can’t send a “User Create” payload to a “Product” actor.