Skip to main content

Handler

Trait Handler 

Source
pub trait Handler: Send + Sync {
    type Output: Serialize;

    // Required method
    fn handle(
        &self,
        matches: &ArgMatches,
        ctx: &CommandContext,
    ) -> HandlerResult<Self::Output>;
}
Expand description

Trait for thread-safe command handlers.

Handlers must be Send + Sync and use immutable &self.

Required Associated Types§

Source

type Output: Serialize

The output type produced by this handler (must be serializable)

Required Methods§

Source

fn handle( &self, matches: &ArgMatches, ctx: &CommandContext, ) -> HandlerResult<Self::Output>

Execute the handler with the given matches and context.

Implementors§

Source§

impl<F, T, R> Handler for FnHandler<F, T, R>
where F: Fn(&ArgMatches, &CommandContext) -> R + Send + Sync, R: IntoHandlerResult<T>, T: Serialize + Send + Sync,

Source§

impl<F, T, R> Handler for SimpleFnHandler<F, T, R>
where F: Fn(&ArgMatches) -> R + Send + Sync, R: IntoHandlerResult<T>, T: Serialize + Send + Sync,