common: Remove RawExt in favor of inherent impl
This commit is contained in:
parent
57e8b77d87
commit
13e53ea6d5
@ -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>,
|
||||
}
|
||||
|
@ -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>,
|
||||
}
|
||||
|
@ -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>,
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user