Trait appliance::HandledBy [−][src]
A dual trait for Handler
. For any type of messages M
and any type of handlers H
,
if impl Handler<M> for H
, then impl HandledBy<H> for M
. I.e. we can either ask
“which messages can be handled by this appliance” or “which appliances can handle this message”,
and the answers to these questions are dual. The trait HandledBy
answers the second
question.
Normally one should always implement Handler<M>
, unless for some reason it is impossible
to do. The dual HandledBy
impl is then provided automatically.
Generic methods, on the other hand, should use the trait constraint T: HandledBy<H>
, since
the set of types for which T: HandledBy<H>
is strictly larger than those for which
H: Handler<T>
. An example where the client would need to implement HandledBy
is if they
want to add custom messages for a library-provided handler type.
Required methods
fn handle_by(self, handler: &mut H) -> Self::Result
[src]
Handle the given message with the provided handler.
The return type is wrapped in order to remove generic parameters from this function.
The actual result value can be recovered with ResultWrapper::downcast
if the type
of the result is known.