pub trait Command:
Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &str;
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 Arguments,
app: &'life2 Application,
) -> Pin<Box<dyn Future<Output = Result<i32>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn description(&self) -> &str { ... }
fn help(&self) -> Option<&str> { ... }
}Expand description
A console command.
use rainier_console::{Arguments, Command};
use rainier_container::Application;
use rainier_support::Result;
struct Greet;
#[async_trait::async_trait]
impl Command for Greet {
fn name(&self) -> &str { "greet" }
fn description(&self) -> &str { "Say hello" }
async fn handle(&self, args: &Arguments, _app: &Application) -> Result<i32> {
println!("Hello, {}", args.argument(0).unwrap_or("world"));
Ok(0)
}
}Required Methods§
Sourcefn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 Arguments,
app: &'life2 Application,
) -> Pin<Box<dyn Future<Output = Result<i32>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 Arguments,
app: &'life2 Application,
) -> Pin<Box<dyn Future<Output = Result<i32>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Run it, returning an exit code.
Provided Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
A one-line summary, shown in the command list.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".