Skip to main content

Handler

Trait Handler 

Source
pub trait Handler {
    type Event: Serialize + 'static;
    type Output: Serialize;
    type Outcome: HandlerOutcome<Self::Output, Self::Event>;

    // Required method
    fn handle(
        &mut self,
        matches: &ArgMatches,
        ctx: &CommandContext,
        results: &mut Results<Self::Event>,
    ) -> Result<Self::Outcome, Error>;

    // Provided method
    fn expected_args(&self) -> Vec<ExpectedArg> { ... }
}

Required Associated Types§

Source

type Event: Serialize + 'static

The type of the values the command produces while it runs, or NoEvents for a command that produces none, which is what emits_events reads.

Source

type Output: Serialize

Source

type Outcome: HandlerOutcome<Self::Output, Self::Event>

Output for a batch command, Summary for one that declares events: HandlerOutcome admits the first only under NoEvents.

Required Methods§

Source

fn handle( &mut self, matches: &ArgMatches, ctx: &CommandContext, results: &mut Results<Self::Event>, ) -> Result<Self::Outcome, Error>

Provided Methods§

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<F, E, T, R> Handler for EventsFnHandler<F, E, T, R>
where F: FnMut(&ArgMatches, &CommandContext, &mut Results<E>) -> R, R: IntoSummaryResult<T>, E: Serialize + 'static, T: Serialize,

Source§

impl<F, T, R> Handler for FnHandler<F, T, R>

Source§

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