samod_core/actors/hub/
dispatched_command.rs

1use crate::actors::hub::CommandId;
2
3use super::HubEvent;
4
5/// A command that has been prepared for execution with a unique identifier.
6///
7/// `DispatchedCommand` represents a command that has been assigned a unique
8/// `CommandId` and wrapped in an `Event` ready for processing. This structure
9/// allows callers to track command completion by matching the command ID
10/// with results returned from `EventResults::completed_commands`.
11///
12/// ## Usage Pattern
13///
14/// 1. Create a command using `Event` static methods (e.g., `Event::create_connection(ConnDirection::Outgoing)`)
15/// 2. Store the `command_id` to track completion
16/// 3. Pass the `event` to `Samod::handle_event`
17/// 4. Check for completion using the `command_id` in subsequent `EventResults`
18pub struct DispatchedCommand {
19    /// The unique identifier for this command.
20    ///
21    /// This ID can be used to match command results when they become available
22    /// in `EventResults::completed_commands`.
23    pub command_id: CommandId,
24
25    /// The event containing the command to be processed.
26    ///
27    /// This event should be passed to `Samod::handle_event` to execute the command.
28    pub event: HubEvent,
29}