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:
- select the first item accepted by the matcher;
- call
Middleware::before; - call
Handler::handle; - call
Middleware::after.
Processing stops at the first error. In particular, after only runs when
both before and the handler succeed.