From 6d868908cbcb6089dc5685e8dcbd049882828b1b Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 26 Jan 2023 12:44:19 +0100 Subject: [PATCH] refactor(sdk): Remove unused Result --- bindings/matrix-sdk-ffi/src/sliding_sync.rs | 2 +- crates/matrix-sdk/src/sliding_sync.rs | 6 +++--- labs/jack-in/src/client/mod.rs | 2 +- .../sliding-sync-integration-test/src/lib.rs | 20 +++++++++---------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/sliding_sync.rs b/bindings/matrix-sdk-ffi/src/sliding_sync.rs index 42aa135d0..f2853324b 100644 --- a/bindings/matrix-sdk-ffi/src/sliding_sync.rs +++ b/bindings/matrix-sdk-ffi/src/sliding_sync.rs @@ -689,7 +689,7 @@ impl SlidingSync { }))); RUNTIME.spawn(async move { - let stream = inner.stream().unwrap(); + let stream = inner.stream(); pin_mut!(stream); loop { let update = match stream.next().await { diff --git a/crates/matrix-sdk/src/sliding_sync.rs b/crates/matrix-sdk/src/sliding_sync.rs index 359cc77a6..6711a859a 100644 --- a/crates/matrix-sdk/src/sliding_sync.rs +++ b/crates/matrix-sdk/src/sliding_sync.rs @@ -860,13 +860,13 @@ impl SlidingSync { /// Create the inner stream for the view. /// /// Run this stream to receive new updates from the server. - pub fn stream(&self) -> Result> + '_> { + pub fn stream(&self) -> impl Stream> + '_ { let views = self.views.lock_ref().to_vec(); let client = self.client.clone(); debug!(?self.extensions, "Setting view stream going"); - Ok(async_stream::stream! { + async_stream::stream! { let mut remaining_views = views.clone(); let mut remaining_generators: Vec> = views .iter() @@ -987,7 +987,7 @@ impl SlidingSync { debug!("handled"); yield Ok(updates); } - }) + } } } diff --git a/labs/jack-in/src/client/mod.rs b/labs/jack-in/src/client/mod.rs index 689bbdab6..9156a6f07 100644 --- a/labs/jack-in/src/client/mod.rs +++ b/labs/jack-in/src/client/mod.rs @@ -37,7 +37,7 @@ pub async fn run_client( .cold_cache("jack-in-default") .build() .await?; - let stream = syncer.stream().expect("we can build the stream"); + let stream = syncer.stream(); let view = syncer.views.lock_ref().first().expect("we have the full syncer there").clone(); let state = view.state.clone(); let mut ssync_state = state::SlidingSyncState::new(view); diff --git a/testing/sliding-sync-integration-test/src/lib.rs b/testing/sliding-sync-integration-test/src/lib.rs index 7d4dcb380..91c6c177f 100644 --- a/testing/sliding-sync-integration-test/src/lib.rs +++ b/testing/sliding-sync-integration-test/src/lib.rs @@ -75,7 +75,7 @@ mod tests { async fn it_works_smoke_test() -> anyhow::Result<()> { let (_client, sync_proxy_builder) = setup("odo".to_owned(), false).await?; let sync_proxy = sync_proxy_builder.add_fullsync_view().build().await?; - let stream = sync_proxy.stream()?; + let stream = sync_proxy.stream(); pin_mut!(stream); let room_summary = stream.next().await.context("No room summary found, loop ended unsuccessfully")?; @@ -109,7 +109,7 @@ mod tests { assert!(sync_proxy.view(view_name_3).is_none()); - let stream = sync_proxy.stream()?; + let stream = sync_proxy.stream(); pin_mut!(stream); let room_summary = stream.next().await.context("No room summary found, loop ended unsuccessfully")?; @@ -120,7 +120,7 @@ mod tests { assert!(sync_proxy.add_view(build_view(view_name_3)?).is_none()); // we need to restart the stream after every view listing update - let stream = sync_proxy.stream()?; + let stream = sync_proxy.stream(); pin_mut!(stream); let mut saw_update = false; @@ -210,7 +210,7 @@ mod tests { bail!("but we just added that view!"); }; - let stream = sync_proxy.stream()?; + let stream = sync_proxy.stream(); pin_mut!(stream); let Some(room_summary ) = stream.next().await else { bail!("No room summary found, loop ended unsuccessfully"); @@ -224,7 +224,7 @@ mod tests { }; // we need to restart the stream after every view listing update - let stream = sync_proxy.stream()?; + let stream = sync_proxy.stream(); pin_mut!(stream); // Let's trigger an update by sending a message to room pos=3, making it move to @@ -266,7 +266,7 @@ mod tests { assert!(sync_proxy.add_view(view_2).is_none()); // we need to restart the stream after every view listing update - let stream = sync_proxy.stream()?; + let stream = sync_proxy.stream(); pin_mut!(stream); let mut saw_update = false; @@ -348,7 +348,7 @@ mod tests { assert_eq!(view.state.get_cloned(), SlidingSyncState::Cold, "view isn't cold"); assert_eq!(full_view.state.get_cloned(), SlidingSyncState::Cold, "full isn't cold"); - let stream = sync_proxy.stream()?; + let stream = sync_proxy.stream(); pin_mut!(stream); // exactly one poll! @@ -422,7 +422,7 @@ mod tests { .build()?; let sync_proxy = sync_proxy_builder.add_view(sliding_window_view).build().await?; let view = sync_proxy.view("sliding").context("but we just added that view!")?; - let stream = sync_proxy.stream()?; + let stream = sync_proxy.stream(); pin_mut!(stream); let room_summary = stream.next().await.context("No room summary found, loop ended unsuccessfully")?; @@ -610,7 +610,7 @@ mod tests { .build()?; let sync_proxy = sync_proxy_builder.add_view(sliding_window_view).build().await?; let view = sync_proxy.view("sliding").context("but we just added that view!")?; - let stream = sync_proxy.stream()?; + let stream = sync_proxy.stream(); pin_mut!(stream); let room_summary = stream.next().await.context("No room summary found, loop ended unsuccessfully")?; @@ -893,7 +893,7 @@ mod tests { .await?; let growing_sync = sync_proxy.view("growing").context("but we just added that view!")?; // let's catch it up fully. - let stream = sync_proxy.stream()?; + let stream = sync_proxy.stream(); pin_mut!(stream); while growing_sync.state.get_cloned() != SlidingSyncState::Live { // we wait until growing sync is all done, too