pub struct Order {
pub id: OrderId,
pub user_id: UserId,
pub product_id: ProductId,
pub quantity: u32,
pub total: f64,
pub status: String,
}Fields§
§id: OrderId§user_id: UserId§product_id: ProductId§quantity: u32§total: f64§status: StringImplementations§
Source§impl Order
impl Order
Sourcepub fn new(
id: OrderId,
user_id: UserId,
product_id: ProductId,
quantity: u32,
total: f64,
) -> Self
pub fn new( id: OrderId, user_id: UserId, product_id: ProductId, quantity: u32, total: f64, ) -> Self
Creates a new Order instance.
§Arguments
id- Unique identifier (typically set by the actor system)user_id- ID of the user placing the orderproduct_id- ID of the product being orderedquantity- Quantity orderedtotal- Total price for the order
§Notes
The order is initialized with status “Created”. This constructor is kept for backward compatibility.
Trait Implementations§
Source§impl ActorClient<Order> for OrderClient
impl ActorClient<Order> for OrderClient
Source§type Error = OrderError
type Error = OrderError
The resource-specific error type.
Source§fn map_error(e: FrameworkError) -> Self::Error
fn map_error(e: FrameworkError) -> Self::Error
Map framework errors to the specific resource error type.
Source§impl ActorEntity for Order
impl ActorEntity for Order
Source§fn from_create_params(
id: Self::Id,
params: Self::Create,
) -> Result<Self, Self::Error>
fn from_create_params( id: Self::Id, params: Self::Create, ) -> Result<Self, Self::Error>
Creates a new Order from creation parameters.
Source§fn on_create<'life0, 'life1, 'async_trait>(
&'life0 mut self,
(user_client, product_client): &'life1 Self::Context,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_create<'life0, 'life1, 'async_trait>(
&'life0 mut self,
(user_client, product_client): &'life1 Self::Context,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Validates the order by checking User existence and reserving Product stock.
Source§type Id = OrderId
type Id = OrderId
The unique identifier for this entity (e.g., String, Uuid, u64).
Must be convertible from u32 for automatic ID generation.
Source§type Create = OrderCreate
type Create = OrderCreate
The data required to create a new instance (DTO - Data Transfer Object).
Source§type ActionResult = ()
type ActionResult = ()
The result type returned by custom actions.
Source§type Context = (UserClient, ProductClient)
type Context = (UserClient, ProductClient)
The runtime context (dependencies) injected into the actor.
Use
() if no dependencies are needed.Source§type Error = OrderError
type Error = OrderError
The error type for this entity.
Must implement std::error::Error for proper error propagation. Read more
Source§fn handle_action<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_action: Self::Action,
_ctx: &'life1 Self::Context,
) -> Pin<Box<dyn Future<Output = Result<Self::ActionResult, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_action<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_action: Self::Action,
_ctx: &'life1 Self::Context,
) -> Pin<Box<dyn Future<Output = Result<Self::ActionResult, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Handle a custom resource-specific action.
Source§fn on_update<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_update: Self::Update,
_ctx: &'life1 Self::Context,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_update<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_update: Self::Update,
_ctx: &'life1 Self::Context,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when an update request is received.
Source§fn on_delete<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 Self::Context,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_delete<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 Self::Context,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called immediately before the entity is removed from the system.
Auto Trait Implementations§
impl Freeze for Order
impl RefUnwindSafe for Order
impl Send for Order
impl Sync for Order
impl Unpin for Order
impl UnwindSafe for Order
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more