Inline handle_sync_events_wrapped

It was only used in one place.
This commit is contained in:
Jonas Platte 2021-09-09 20:44:25 +02:00
parent b94faa3121
commit 8f46a87f52
No known key found for this signature in database
GPG key ID: CC154DE0E30B7C67

View file

@ -211,7 +211,16 @@ impl Client {
room: &Option<room::Room>,
events: &[Raw<T>],
) -> serde_json::Result<()> {
self.handle_sync_events_wrapped(kind, room, events, |x| x).await
#[derive(Deserialize)]
struct ExtractType<'a> {
#[serde(borrow, rename = "type")]
event_type: Cow<'a, str>,
}
self.handle_sync_events_wrapped_with(room, events, std::convert::identity, |raw| {
Ok((kind, raw.deserialize_as::<ExtractType>()?.event_type))
})
.await
}
pub(crate) async fn handle_sync_state_events(
@ -268,25 +277,6 @@ impl Client {
.await
}
async fn handle_sync_events_wrapped<'a, T: 'a, U: 'a>(
&self,
kind: EventKind,
room: &Option<room::Room>,
events: &'a [U],
get_event: impl Fn(&'a U) -> &'a Raw<T>,
) -> Result<(), serde_json::Error> {
#[derive(Deserialize)]
struct ExtractType<'a> {
#[serde(borrow, rename = "type")]
event_type: Cow<'a, str>,
}
self.handle_sync_events_wrapped_with(room, events, get_event, |raw| {
Ok((kind, raw.deserialize_as::<ExtractType>()?.event_type))
})
.await
}
async fn handle_sync_events_wrapped_with<'a, T: 'a, U: 'a>(
&self,
room: &Option<room::Room>,