diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index d65f7b1d..23f6efc3 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -888,9 +888,13 @@ impl Client { /// [`Client`] also implements the `EventHandlerContext` trait /// so you don't have to clone your client into the event handler manually. /// - /// Invalid context arguments, for example a [`Room`][room::Room] as an - /// argument to an account data event handler, will result in the event - /// handler being skipped and an error logged. + /// Some context arguments are not universally applicable. A context + /// argument that isn't available for the given event type will result in + /// the event handler being skipped and an error being logged. The following + /// context argument types are only available for a subset of event types: + /// + /// * [`Room`][room::Room] is only available for room-specific events, i.e. + /// not for events like global account data events or presence events /// /// [`EventHandlerContext`]: crate::event_handler::EventHandlerContext /// diff --git a/matrix_sdk/src/event_handler.rs b/matrix_sdk/src/event_handler.rs index 43df38c5..ba1a031c 100644 --- a/matrix_sdk/src/event_handler.rs +++ b/matrix_sdk/src/event_handler.rs @@ -134,6 +134,12 @@ impl EventHandlerContext for Client { } } +/// This event handler context argument is only applicable to room-specific +/// events. +/// +/// Trying to use it in the event handler for another event, for example a +/// global account data or presence event, will result in the event handler +/// being skipped and an error getting logged. impl EventHandlerContext for room::Room { fn from_data(data: &EventHandlerData<'_>) -> Option { data.room.clone()