rush_sync_server/commands/
command.rs

1use crate::core::prelude::*;
2
3#[async_trait::async_trait]
4pub trait Command: Send + Sync + std::fmt::Debug + 'static {
5    fn name(&self) -> &'static str;
6    fn description(&self) -> &'static str;
7    fn matches(&self, command: &str) -> bool;
8
9    // Hauptausführung - immer implementieren
10    async fn execute(&self, args: &[&str]) -> Result<String> {
11        // Einfach & robust: vorhandene Sync-Logik nutzen
12        self.execute_sync(args)
13    }
14
15    // Optional: Sync-Fallback für Commands die es brauchen
16    fn execute_sync(&self, args: &[&str]) -> Result<String> {
17        // Default: Blockiert auf async execute
18        futures::executor::block_on(self.execute(args))
19    }
20
21    fn priority(&self) -> u8 {
22        50
23    }
24    fn is_available(&self) -> bool {
25        true
26    }
27}