Inline handle_sync_events_wrapped

It was only used in one place.
master
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
1 changed files with 10 additions and 20 deletions

View File

@ -211,7 +211,16 @@ impl Client {
room: &Option<room::Room>, room: &Option<room::Room>,
events: &[Raw<T>], events: &[Raw<T>],
) -> serde_json::Result<()> { ) -> 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( pub(crate) async fn handle_sync_state_events(
@ -268,25 +277,6 @@ impl Client {
.await .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>( async fn handle_sync_events_wrapped_with<'a, T: 'a, U: 'a>(
&self, &self,
room: &Option<room::Room>, room: &Option<room::Room>,