Skip to main content

LocalHandler

Trait LocalHandler 

Source
pub trait LocalHandler {
    type Output: Serialize;

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

Trait for local (single-threaded) command handlers.

Unlike Handler, this trait:

  • Does NOT require Send + Sync
  • Takes &mut self instead of &self
  • Allows handlers to mutate their internal state directly

Required Associated Types§

Source

type Output: Serialize

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

Required Methods§

Source

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

Execute the handler with the given matches and context.

Implementors§

Source§

impl<F, T, R> LocalHandler for LocalFnHandler<F, T, R>

Source§

impl<F, T, R> LocalHandler for LocalSimpleFnHandler<F, T, R>
where F: FnMut(&ArgMatches) -> R, R: IntoHandlerResult<T>, T: Serialize,