reactive_graph_command_api/
command_manager.rs

1use async_trait::async_trait;
2use springtime_di::injectable;
3
4use reactive_graph_command_model::Command;
5use reactive_graph_command_model::error::NoSuchCommand;
6use reactive_graph_graph::EntityType;
7use reactive_graph_lifecycle::Lifecycle;
8
9use crate::CommandRegistrationError;
10
11#[injectable]
12#[async_trait]
13pub trait CommandManager: Send + Sync + Lifecycle {
14    /// Returns the command with the given name.
15    fn get_command(&self, name: &str) -> Result<Command, NoSuchCommand>;
16
17    /// Returns all commands.
18    fn get_commands(&self) -> Vec<Command>;
19
20    /// Registers a new command.
21    fn register_command(&self, command: Command) -> Result<(), CommandRegistrationError>;
22
23    /// Registers a new singleton command.
24    fn register_singleton_command(&self, command: Command, entity_type: EntityType) -> Result<(), CommandRegistrationError>;
25}