actor_sample/product_actor/actions.rs
1//! Custom actions for the Product actor.
2//!
3//! This module defines the resource-specific operations (Actions) that can be performed
4//! on a [`Product`](crate::model::Product) entity, such as checking stock or reserving items.
5//! These actions are handled by the [`ActorEntity::handle_action`](actor_framework::ActorEntity::handle_action) method.
6//!
7//! See [`impl ActorEntity for Product`](crate::model::Product#impl-ActorEntity-for-Product) for the implementation details.
8
9/// Custom actions for Product entities.
10///
11/// These actions represent resource-specific operations that can be performed
12/// on a product beyond standard CRUD operations.
13#[derive(Debug, Clone)]
14pub enum ProductAction {
15 /// Checks the current stock level without modifying it.
16 #[allow(dead_code)]
17 CheckStock,
18 /// Reserves a specified amount of stock.
19 ///
20 /// # Arguments
21 /// * `u32` - The quantity to reserve
22 ///
23 /// # Errors
24 /// Will fail if the requested amount exceeds available stock.
25 ReserveStock(u32),
26}
27
28/// Results from ProductActions - variants match 1:1 with ProductAction
29#[derive(Debug, Clone)]
30pub enum ProductActionResult {
31 /// Result from CheckStock action - returns the current stock level
32 CheckStock(u32),
33 /// Result from ReserveStock action - returns unit on success
34 ReserveStock(()),
35}