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: {
|
response: {
|
||||||
/// Account data content for the given type.
|
/// Account data content for the given type.
|
||||||
///
|
///
|
||||||
/// Use `ruma_common::events::RawExt` for deserialization.
|
/// Use [`Raw::deserialize_content`] for deserialization.
|
||||||
#[ruma_api(body)]
|
#[ruma_api(body)]
|
||||||
pub account_data: Raw<AnyGlobalAccountDataEventContent>,
|
pub account_data: Raw<AnyGlobalAccountDataEventContent>,
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ pub mod v3 {
|
|||||||
response: {
|
response: {
|
||||||
/// Account data content for the given type.
|
/// Account data content for the given type.
|
||||||
///
|
///
|
||||||
/// Use `ruma_common::events::RawExt` for deserialization.
|
/// Use [`Raw::deserialize_content`] for deserialization.
|
||||||
#[ruma_api(body)]
|
#[ruma_api(body)]
|
||||||
pub account_data: Raw<AnyRoomAccountDataEventContent>,
|
pub account_data: Raw<AnyRoomAccountDataEventContent>,
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ pub mod v3 {
|
|||||||
/// The content of the state event.
|
/// The content of the state event.
|
||||||
///
|
///
|
||||||
/// Since the inner type of the `Raw` does not implement `Deserialize`, you need to use
|
/// 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)]
|
#[ruma_api(body)]
|
||||||
pub content: Raw<AnyStateEventContent>,
|
pub content: Raw<AnyStateEventContent>,
|
||||||
}
|
}
|
||||||
|
@ -230,14 +230,9 @@ pub trait RedactContent {
|
|||||||
fn redact(self, version: &RoomVersionId) -> Self::Redacted;
|
fn redact(self, version: &RoomVersionId) -> Self::Redacted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extension trait for [`Raw<_>`][crate::serde::Raw].
|
impl<T: EventContent> Raw<T> {
|
||||||
pub trait RawExt<T: EventContent> {
|
|
||||||
/// Try to deserialize the JSON as an event's content.
|
/// Try to deserialize the JSON as an event's content.
|
||||||
fn deserialize_content(&self, event_type: &str) -> serde_json::Result<T>;
|
pub 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> {
|
|
||||||
T::from_parts(event_type, self.json())
|
T::from_parts(event_type, self.json())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use ruma_common::{
|
|||||||
room::{ImageInfo, ThumbnailInfo},
|
room::{ImageInfo, ThumbnailInfo},
|
||||||
sticker::StickerEventContent,
|
sticker::StickerEventContent,
|
||||||
AnyMessageLikeEvent, AnyMessageLikeEventContent, AnySyncMessageLikeEvent, MessageLikeEvent,
|
AnyMessageLikeEvent, AnyMessageLikeEventContent, AnySyncMessageLikeEvent, MessageLikeEvent,
|
||||||
RawExt, Unsigned,
|
Unsigned,
|
||||||
},
|
},
|
||||||
mxc_uri, room_id,
|
mxc_uri, room_id,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
|
@ -8,7 +8,7 @@ use ruma_common::{
|
|||||||
avatar::{ImageInfo, RoomAvatarEventContent},
|
avatar::{ImageInfo, RoomAvatarEventContent},
|
||||||
ThumbnailInfo,
|
ThumbnailInfo,
|
||||||
},
|
},
|
||||||
AnyRoomEvent, AnyStateEvent, AnyStateEventContent, AnySyncStateEvent, RawExt, StateEvent,
|
AnyRoomEvent, AnyStateEvent, AnyStateEventContent, AnySyncStateEvent, StateEvent,
|
||||||
SyncStateEvent, Unsigned,
|
SyncStateEvent, Unsigned,
|
||||||
},
|
},
|
||||||
mxc_uri, room_alias_id, room_id,
|
mxc_uri, room_alias_id, room_id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user