diff --git a/crates/ruma-client-api/src/config/get_global_account_data.rs b/crates/ruma-client-api/src/config/get_global_account_data.rs index 033decfc..123bf4ea 100644 --- a/crates/ruma-client-api/src/config/get_global_account_data.rs +++ b/crates/ruma-client-api/src/config/get_global_account_data.rs @@ -34,7 +34,7 @@ pub mod v3 { response: { /// Account data content for the given type. /// - /// Use `ruma_common::events::RawExt` for deserialization. + /// Use [`Raw::deserialize_content`] for deserialization. #[ruma_api(body)] pub account_data: Raw, } diff --git a/crates/ruma-client-api/src/config/get_room_account_data.rs b/crates/ruma-client-api/src/config/get_room_account_data.rs index 3df2974d..2f61140a 100644 --- a/crates/ruma-client-api/src/config/get_room_account_data.rs +++ b/crates/ruma-client-api/src/config/get_room_account_data.rs @@ -38,7 +38,7 @@ pub mod v3 { response: { /// Account data content for the given type. /// - /// Use `ruma_common::events::RawExt` for deserialization. + /// Use [`Raw::deserialize_content`] for deserialization. #[ruma_api(body)] pub account_data: Raw, } diff --git a/crates/ruma-client-api/src/state/get_state_events_for_key.rs b/crates/ruma-client-api/src/state/get_state_events_for_key.rs index 84021958..10c1da86 100644 --- a/crates/ruma-client-api/src/state/get_state_events_for_key.rs +++ b/crates/ruma-client-api/src/state/get_state_events_for_key.rs @@ -28,7 +28,7 @@ pub mod v3 { /// The content of the state event. /// /// Since the inner type of the `Raw` does not implement `Deserialize`, you need to use - /// `ruma_common::events::RawExt` to deserialize it. + /// [`Raw::deserialize_content`] to deserialize it. #[ruma_api(body)] pub content: Raw, } diff --git a/crates/ruma-common/src/events.rs b/crates/ruma-common/src/events.rs index 56c71190..57586848 100644 --- a/crates/ruma-common/src/events.rs +++ b/crates/ruma-common/src/events.rs @@ -230,14 +230,9 @@ pub trait RedactContent { fn redact(self, version: &RoomVersionId) -> Self::Redacted; } -/// Extension trait for [`Raw<_>`][crate::serde::Raw]. -pub trait RawExt { +impl Raw { /// Try to deserialize the JSON as an event's content. - fn deserialize_content(&self, event_type: &str) -> serde_json::Result; -} - -impl RawExt for Raw { - fn deserialize_content(&self, event_type: &str) -> serde_json::Result { + pub fn deserialize_content(&self, event_type: &str) -> serde_json::Result { T::from_parts(event_type, self.json()) } } diff --git a/crates/ruma-common/tests/events/message_event.rs b/crates/ruma-common/tests/events/message_event.rs index 20536d9e..f9b3c5e6 100644 --- a/crates/ruma-common/tests/events/message_event.rs +++ b/crates/ruma-common/tests/events/message_event.rs @@ -8,7 +8,7 @@ use ruma_common::{ room::{ImageInfo, ThumbnailInfo}, sticker::StickerEventContent, AnyMessageLikeEvent, AnyMessageLikeEventContent, AnySyncMessageLikeEvent, MessageLikeEvent, - RawExt, Unsigned, + Unsigned, }, mxc_uri, room_id, serde::Raw, diff --git a/crates/ruma-common/tests/events/state_event.rs b/crates/ruma-common/tests/events/state_event.rs index 8a60a020..29ee7c32 100644 --- a/crates/ruma-common/tests/events/state_event.rs +++ b/crates/ruma-common/tests/events/state_event.rs @@ -8,7 +8,7 @@ use ruma_common::{ avatar::{ImageInfo, RoomAvatarEventContent}, ThumbnailInfo, }, - AnyRoomEvent, AnyStateEvent, AnyStateEventContent, AnySyncStateEvent, RawExt, StateEvent, + AnyRoomEvent, AnyStateEvent, AnyStateEventContent, AnySyncStateEvent, StateEvent, SyncStateEvent, Unsigned, }, mxc_uri, room_alias_id, room_id,