Skip to main content

Command

Trait Command 

Source
pub trait Command:
    Send
    + Sync
    + 'static {
    const NAME: &'static str;
    const DESCRIPTION: &'static str = "";

    // Required method
    fn handle(
        args: &[String],
    ) -> impl Future<Output = Result<(), AppError>> + Send;
}
Expand description

A named CLI command, run once, synchronously, in the same process that dispatched it - see this crate’s own module doc for the full comparison against larust_queue::Job.

Required Associated Constants§

Source

const NAME: &'static str

The name typed after xr to run this command, e.g. xr report:posts names a command whose NAME is "report:posts". Colon-namespaced by convention (Laravel’s own make:model, queue:work), never enforced - any string works.

Provided Associated Constants§

Source

const DESCRIPTION: &'static str = ""

A one-line description, shown by xr command:list. Optional - defaults to empty rather than requiring every command to supply one, since a name alone is often self-explanatory.

Required Methods§

Source

fn handle(args: &[String]) -> impl Future<Output = Result<(), AppError>> + Send

Runs the command. args is every token after the command’s own name (xr report:posts --format=json hands ["--format=json"]) - parsing them is the command’s own job, the same “no framework-imposed argument-parsing DSL” stance Job/Notification already take for their own payloads.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§