events: Simplify RawExt
* Remove redundant where clause * Clean up documentation
This commit is contained in:
parent
34134267c6
commit
9b38538579
@ -284,15 +284,11 @@ pub trait RedactContent {
|
|||||||
|
|
||||||
/// Extension trait for Raw<EventContent>
|
/// Extension trait for Raw<EventContent>
|
||||||
pub trait RawExt<T: 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>;
|
fn deserialize_content(self, event_type: &str) -> Result<T, serde_json::Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: EventContent> RawExt<T> for Raw<T>
|
impl<T: EventContent> RawExt<T> for Raw<T> {
|
||||||
where
|
|
||||||
T: EventContent,
|
|
||||||
{
|
|
||||||
/// Try to deserialize the JSON as event content
|
|
||||||
fn deserialize_content(self, event_type: &str) -> Result<T, serde_json::Error> {
|
fn deserialize_content(self, event_type: &str) -> Result<T, serde_json::Error> {
|
||||||
T::from_parts(event_type, self.into_json())
|
T::from_parts(event_type, self.into_json())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user