events: Simplify RawExt

* Remove redundant where clause
* Clean up documentation
This commit is contained in:
Jonas Platte 2021-05-15 13:57:50 +02:00
parent 34134267c6
commit 9b38538579
No known key found for this signature in database
GPG Key ID: 7D261D771D915378

View File

@ -284,15 +284,11 @@ pub trait RedactContent {
/// Extension trait for Raw<EventContent>
pub trait RawExt<T: EventContent> {
/// Try to deserialize the JSON as event content
/// Try to deserialize the JSON as an event's content.
fn deserialize_content(self, event_type: &str) -> Result<T, serde_json::Error>;
}
impl<T: EventContent> RawExt<T> for Raw<T>
where
T: EventContent,
{
/// Try to deserialize the JSON as event content
impl<T: EventContent> RawExt<T> for Raw<T> {
fn deserialize_content(self, event_type: &str) -> Result<T, serde_json::Error> {
T::from_parts(event_type, self.into_json())
}