rush_sync_server/commands/
command.rs1use crate::core::prelude::*;
2use std::future::Future;
3use std::pin::Pin;
4
5pub trait Command: Send + Sync + std::fmt::Debug + 'static {
6 fn name(&self) -> &'static str;
7 fn description(&self) -> &'static str;
8 fn matches(&self, command: &str) -> bool;
9 fn execute_sync(&self, args: &[&str]) -> Result<String>;
10
11 fn execute_async<'a>(
12 &'a self,
13 args: &'a [&'a str],
14 ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'a>> {
15 Box::pin(async move { self.execute_sync(args) })
16 }
17
18 fn supports_async(&self) -> bool {
19 false
20 }
21 fn priority(&self) -> u8 {
22 50
23 }
24 fn is_available(&self) -> bool {
25 true
26 }
27}