Skip to main content

dispatch

Function dispatch 

Source
pub fn dispatch<M, W, Item, Input, Output, Error>(
    dispatcher: &mut Dispatcher<M, W>,
    table: &[Item],
    input: &Input,
) -> Result<Output, DispatchError<Error>>
where M: Matcher<Item, Input>, W: Middleware<Item, Input, Output, Error>, Item: Handler<Input = Input, Output = Output, Error = Error>,
Expand description

Dispatches input to the first matching item in table.

Execution order is:

  1. select the first item accepted by the matcher;
  2. call Middleware::before;
  3. call Handler::handle;
  4. call Middleware::after.

Processing stops at the first error. In particular, after only runs when both before and the handler succeed.