Expand description
Chaining branch combinators.
This module provides functions for chaining branching Handler
combinators like try_and
and or
. These chaining combinators are often more ergonomic when combining more than two
handlers and can also improve syntax and readability by more naturally grouping together
branches in complex expressions.
Chaining is either static or dynamic. Static chaining refers to chaining a fixed number of
handlers of any types. Dynamic chaining refers to chaining an unknown number of handlers of the
same type. The boxed
function can be used to allow different handler types with dynamic
chaining via type erasure.
Functions in this module accept tuples of handlers for static chaining and Vec
s of handlers
for dynamic chaining. Handlers are always executed in order.
Structs§
Traits§
- Types that describe a sequence of event handlers that can be combined via
and
. - Types that describe a sequence of event handlers that can be combined via
or
. - Types that describe a sequence of event handlers that can be combined via
try_and
. - Types that describe a sequence of event handlers that can be combined via
try_or
.
Functions§
- Executes the handlers in a tuple or
Vec
in order until a handler does not match the event. If all handlers match, then the output of the last handler in the sequence is returned, otherwiseHandled::Unmatched
. - Executes the handlers in a tuple or
Vec
in order until a handler matches the event. If any handler matches, then the output of that handler is returned, otherwiseHandled::Unmatched
. - Executes the handlers in a tuple or
Vec
in order until a handler does not match the event or returns an error. If a handler matches but returns an error, the error is returned. If all handlers match and no handlers return an error, then the output of the last handler in the sequence is returned, otherwiseHandled::Unmatched
. - Executes the handlers in a tuple or
Vec
in order until a handler matches the event and does not return an error. If any handler matches and returns a non-error, then the output of that handler is returned, otherwiseHandled::Unmatched
.