common: Remove RawExt in favor of inherent impl

This commit is contained in:
Jonas Platte 2022-03-14 19:01:03 +01:00
parent 57e8b77d87
commit 13e53ea6d5
No known key found for this signature in database
GPG Key ID: BBA95679259D342F
6 changed files with 7 additions and 12 deletions

View File

@ -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<AnyGlobalAccountDataEventContent>,
}

View File

@ -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<AnyRoomAccountDataEventContent>,
}

View File

@ -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<AnyStateEventContent>,
}

View File

@ -230,14 +230,9 @@ pub trait RedactContent {
fn redact(self, version: &RoomVersionId) -> Self::Redacted;
}
/// Extension trait for [`Raw<_>`][crate::serde::Raw].
pub trait RawExt<T: EventContent> {
impl<T: EventContent> Raw<T> {
/// Try to deserialize the JSON as an event's content.
fn deserialize_content(&self, event_type: &str) -> serde_json::Result<T>;
}
impl<T: EventContent> RawExt<T> for Raw<T> {
fn deserialize_content(&self, event_type: &str) -> serde_json::Result<T> {
pub fn deserialize_content(&self, event_type: &str) -> serde_json::Result<T> {
T::from_parts(event_type, self.json())
}
}

View File

@ -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,

View File

@ -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,