From 9b793eeb68902fc6794e9dc54cfc41323ff72169 Mon Sep 17 00:00:00 2001 From: Yuyi Wang Date: Tue, 13 Sep 2022 06:24:57 +0800 Subject: [PATCH] Remove `futures` & `futures-lite` and use `futures-util` directily. (#5172) --- core/tauri/Cargo.toml | 3 +-- core/tauri/src/api/http.rs | 6 +++--- core/tauri/src/async_runtime.rs | 3 +-- core/tauri/src/command.rs | 2 +- core/tauri/src/updater/core.rs | 2 +- tooling/webdriver/src/server.rs | 4 ++-- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/core/tauri/Cargo.toml b/core/tauri/Cargo.toml index 9391adaf5..d1a4752ae 100644 --- a/core/tauri/Cargo.toml +++ b/core/tauri/Cargo.toml @@ -48,7 +48,7 @@ normal = [ "attohttpc", "reqwest" ] serde_json = { version = "1.0", features = [ "raw_value" ] } serde = { version = "1.0", features = [ "derive" ] } tokio = { version = "1", features = [ "rt", "rt-multi-thread", "sync", "fs", "io-util" ] } -futures = "0.3" +futures-util = "0.3" uuid = { version = "1", features = [ "v4" ] } url = { version = "2.3" } anyhow = "1.0" @@ -82,7 +82,6 @@ raw-window-handle = "0.5" minisign-verify = { version = "0.2", optional = true } time = { version = "0.3", features = [ "parsing", "formatting" ], optional = true } os_info = { version = "3.5.0", optional = true } -futures-lite = "1.12" regex = { version = "1.6.0", optional = true } glob = "0.3" data-url = { version = "0.1", optional = true } diff --git a/core/tauri/src/api/http.rs b/core/tauri/src/api/http.rs index 97e38cdbe..feae38191 100644 --- a/core/tauri/src/api/http.rs +++ b/core/tauri/src/api/http.rs @@ -599,7 +599,7 @@ impl Response { /// # Examples /// /// ```no_run - /// use futures::StreamExt; + /// use futures_util::StreamExt; /// /// # async fn run() -> Result<(), Box> { /// let client = tauri::api::http::ClientBuilder::new().build()?; @@ -617,8 +617,8 @@ impl Response { #[allow(dead_code)] pub(crate) fn bytes_stream( self, - ) -> impl futures::Stream> { - use futures::StreamExt; + ) -> impl futures_util::Stream> { + use futures_util::StreamExt; self.1.bytes_stream().map(|res| res.map_err(Into::into)) } diff --git a/core/tauri/src/async_runtime.rs b/core/tauri/src/async_runtime.rs index d6c4e1884..4ef9ad015 100644 --- a/core/tauri/src/async_runtime.rs +++ b/core/tauri/src/async_runtime.rs @@ -10,7 +10,6 @@ //! one you need isn't here, you could use types in [`tokio`] directly. //! For custom command handlers, it's recommended to use a plain `async fn` command. -use futures_lite::future::FutureExt; use once_cell::sync::OnceCell; pub use tokio::{ runtime::{Handle as TokioHandle, Runtime as TokioRuntime}, @@ -159,7 +158,7 @@ impl Future for JoinHandle { type Output = crate::Result; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match self.get_mut() { - Self::Tokio(t) => t.poll(cx).map_err(Into::into), + Self::Tokio(t) => Pin::new(t).poll(cx).map_err(Into::into), } } } diff --git a/core/tauri/src/command.rs b/core/tauri/src/command.rs index cc4935cb3..24896156b 100644 --- a/core/tauri/src/command.rs +++ b/core/tauri/src/command.rs @@ -156,7 +156,7 @@ impl<'de, R: Runtime> Deserializer<'de> for CommandItem<'de, R> { #[doc(hidden)] pub mod private { use crate::{InvokeError, InvokeResolver, Runtime}; - use futures::{FutureExt, TryFutureExt}; + use futures_util::{FutureExt, TryFutureExt}; use serde::Serialize; use serde_json::Value; use std::future::Future; diff --git a/core/tauri/src/updater/core.rs b/core/tauri/src/updater/core.rs index 52ff04d06..57085bcfd 100644 --- a/core/tauri/src/updater/core.rs +++ b/core/tauri/src/updater/core.rs @@ -563,7 +563,7 @@ impl Update { let mut buffer = Vec::new(); #[cfg(feature = "reqwest-client")] { - use futures::StreamExt; + use futures_util::StreamExt; let mut stream = response.bytes_stream(); while let Some(chunk) = stream.next().await { let chunk = chunk?; diff --git a/tooling/webdriver/src/server.rs b/tooling/webdriver/src/server.rs index cb507b50c..bc31e1330 100644 --- a/tooling/webdriver/src/server.rs +++ b/tooling/webdriver/src/server.rs @@ -4,7 +4,7 @@ use crate::cli::Args; use anyhow::Error; -use futures::TryFutureExt; +use futures_util::TryFutureExt; use hyper::header::CONTENT_LENGTH; use hyper::http::uri::Authority; use hyper::service::{make_service_fn, service_fn}; @@ -141,7 +141,7 @@ fn map_capabilities(mut json: Value) -> Value { pub async fn run(args: Args, mut _driver: Child) -> Result<(), Error> { #[cfg(unix)] let (signals_handle, signals_task) = { - use futures::StreamExt; + use futures_util::StreamExt; use signal_hook::consts::signal::*; let signals = signal_hook_tokio::Signals::new(&[SIGTERM, SIGINT, SIGQUIT])?;