Expand description
Types and traits related for event handlers. For usage, see
Client::add_event_handler
.
§How it works
The add_event_handler
method registers event handlers of different
signatures by actually storing boxed closures that all have the same
signature of async (EventHandlerData) -> ()
where EventHandlerData
is a
private type that contains all of the data an event handler might need.
The stored closure takes care of deserializing the event which the
EventHandlerData
contains as a (borrowed) serde_json::value::RawValue
,
extracting the context arguments from other fields of EventHandlerData
and
calling / .await
ing the event handler if the previous steps succeeded.
It also logs any errors from the above chain of function calls.
For more details, see the EventHandler
trait.
Structs§
- A custom value registered with
.add_event_handler_context
. - A guard type that removes an event handler when it drops (goes out of scope).
- Handle to remove a registered event handler by passing it to
Client::remove_event_handler
. - The subscriber of an
ObservableEventHandler
. - An observer of events (may be tailored to a room).
- The raw JSON form of an event.
Traits§
- Interface for event handlers.
- Context for an event handler.
- Return types supported for event handlers implement this trait.
- A statically-known event kind/type that can be retrieved from an event sync.