diff --git a/Cargo.lock b/Cargo.lock index ae3436ca..dbcd5060 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -378,7 +378,6 @@ dependencies = [ "async-global-executor", "async-io", "async-lock", - "async-process", "crossbeam-utils", "futures-channel", "futures-core", @@ -2434,7 +2433,6 @@ dependencies = [ name = "iced_futures" version = "0.14.0-dev" dependencies = [ - "async-std", "futures", "iced_core", "log", @@ -5744,12 +5742,12 @@ dependencies = [ name = "todos" version = "0.1.0" dependencies = [ - "async-std", "directories", "iced", "iced_test", "serde", "serde_json", + "tokio", "tracing-subscriber", "uuid", "wasmtimer", diff --git a/Cargo.toml b/Cargo.toml index 5df2f12b..f7318b98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,8 +47,6 @@ debug = ["iced_winit/debug"] thread-pool = ["iced_futures/thread-pool"] # Enables `tokio` as the `executor::Default` on native platforms tokio = ["iced_futures/tokio"] -# Enables `async-std` as the `executor::Default` on native platforms -async-std = ["iced_futures/async-std"] # Enables `smol` as the `executor::Default` on native platforms smol = ["iced_futures/smol"] # Enables querying system information @@ -146,7 +144,6 @@ iced_wgpu = { version = "0.14.0-dev", path = "wgpu" } iced_widget = { version = "0.14.0-dev", path = "widget" } iced_winit = { version = "0.14.0-dev", path = "winit" } -async-std = "1.0" bitflags = "2.0" bytemuck = { version = "1.0", features = ["derive"] } bytes = "1.6" diff --git a/examples/todos/Cargo.toml b/examples/todos/Cargo.toml index 77b776d5..981b9e5f 100644 --- a/examples/todos/Cargo.toml +++ b/examples/todos/Cargo.toml @@ -7,14 +7,14 @@ publish = false [dependencies] iced.workspace = true -iced.features = ["async-std", "debug"] +iced.features = ["tokio", "debug"] serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" uuid = { version = "1.0", features = ["v4", "fast-rng", "serde"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -async-std.workspace = true +tokio.workspace = true directories = "6.0" tracing-subscriber = "0.3" diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index 65a34c64..03e62d3c 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -482,7 +482,6 @@ enum LoadError { #[derive(Debug, Clone)] enum SaveError { - File, Write, Format, } @@ -504,15 +503,7 @@ impl SavedState { } async fn load() -> Result { - use async_std::prelude::*; - - let mut contents = String::new(); - - let mut file = async_std::fs::File::open(Self::path()) - .await - .map_err(|_| LoadError::File)?; - - file.read_to_string(&mut contents) + let contents = tokio::fs::read_to_string(Self::path()) .await .map_err(|_| LoadError::File)?; @@ -520,31 +511,25 @@ impl SavedState { } async fn save(self) -> Result<(), SaveError> { - use async_std::prelude::*; - let json = serde_json::to_string_pretty(&self) .map_err(|_| SaveError::Format)?; let path = Self::path(); if let Some(dir) = path.parent() { - async_std::fs::create_dir_all(dir) + tokio::fs::create_dir_all(dir) .await - .map_err(|_| SaveError::File)?; + .map_err(|_| SaveError::Write)?; } { - let mut file = async_std::fs::File::create(path) - .await - .map_err(|_| SaveError::File)?; - - file.write_all(json.as_bytes()) + tokio::fs::write(path, json.as_bytes()) .await .map_err(|_| SaveError::Write)?; } // This is a simple way to save at most once every couple seconds - async_std::task::sleep(std::time::Duration::from_secs(2)).await; + tokio::time::sleep(std::time::Duration::from_secs(2)).await; Ok(()) } @@ -570,7 +555,7 @@ impl SavedState { } async fn save(self) -> Result<(), SaveError> { - let storage = Self::storage().ok_or(SaveError::File)?; + let storage = Self::storage().ok_or(SaveError::Write)?; let json = serde_json::to_string_pretty(&self) .map_err(|_| SaveError::Format)?; diff --git a/futures/Cargo.toml b/futures/Cargo.toml index 6a49e9e8..e2c342ff 100644 --- a/futures/Cargo.toml +++ b/futures/Cargo.toml @@ -30,10 +30,6 @@ log.workspace = true rustc-hash.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -async-std.workspace = true -async-std.optional = true -async-std.features = ["unstable"] - smol.workspace = true smol.optional = true diff --git a/futures/src/backend/default.rs b/futures/src/backend/default.rs index 842b5927..4418834e 100644 --- a/futures/src/backend/default.rs +++ b/futures/src/backend/default.rs @@ -2,10 +2,9 @@ //! //! - On native platforms, it will use: //! - `backend::native::tokio` when the `tokio` feature is enabled. -//! - `backend::native::async-std` when the `async-std` feature is -//! enabled. //! - `backend::native::smol` when the `smol` feature is enabled. -//! - `backend::native::thread_pool` otherwise. +//! - `backend::native::thread_pool` when the `thread-pool` feature is enabled. +//! - `backend::null` otherwise. //! //! - On Wasm, it will use `backend::wasm::wasm_bindgen`. #[cfg(not(target_arch = "wasm32"))] @@ -13,24 +12,17 @@ mod platform { #[cfg(feature = "tokio")] pub use crate::backend::native::tokio::*; - #[cfg(all(feature = "async-std", not(feature = "tokio"),))] - pub use crate::backend::native::async_std::*; - - #[cfg(all( - feature = "smol", - not(any(feature = "tokio", feature = "async-std")), - ))] + #[cfg(all(feature = "smol", not(feature = "tokio"),))] pub use crate::backend::native::smol::*; #[cfg(all( feature = "thread-pool", - not(any(feature = "tokio", feature = "async-std", feature = "smol")) + not(any(feature = "tokio", feature = "smol")) ))] pub use crate::backend::native::thread_pool::*; #[cfg(not(any( feature = "tokio", - feature = "async-std", feature = "smol", feature = "thread-pool" )))] diff --git a/futures/src/backend/native.rs b/futures/src/backend/native.rs index 85af2c88..e5595bdb 100644 --- a/futures/src/backend/native.rs +++ b/futures/src/backend/native.rs @@ -2,9 +2,6 @@ #[cfg(feature = "tokio")] pub mod tokio; -#[cfg(feature = "async-std")] -pub mod async_std; - #[cfg(feature = "smol")] pub mod smol; diff --git a/futures/src/backend/native/async_std.rs b/futures/src/backend/native/async_std.rs deleted file mode 100644 index be258b26..00000000 --- a/futures/src/backend/native/async_std.rs +++ /dev/null @@ -1,56 +0,0 @@ -//! An `async-std` backend. - -/// An `async-std` executor. -#[derive(Debug)] -pub struct Executor; - -impl crate::Executor for Executor { - fn new() -> Result { - Ok(Self) - } - - #[allow(clippy::let_underscore_future)] - fn spawn(&self, future: impl Future + Send + 'static) { - let _ = async_std::task::spawn(future); - } -} - -pub mod time { - //! Listen and react to time. - use crate::subscription::{self, Hasher, Subscription}; - - /// Returns a [`Subscription`] that produces messages at a set interval. - /// - /// The first message is produced after a `duration`, and then continues to - /// produce more messages every `duration` after that. - pub fn every( - duration: std::time::Duration, - ) -> Subscription { - subscription::from_recipe(Every(duration)) - } - - #[derive(Debug)] - struct Every(std::time::Duration); - - impl subscription::Recipe for Every { - type Output = std::time::Instant; - - fn hash(&self, state: &mut Hasher) { - use std::hash::Hash; - - std::any::TypeId::of::().hash(state); - self.0.hash(state); - } - - fn stream( - self: Box, - _input: subscription::EventStream, - ) -> futures::stream::BoxStream<'static, Self::Output> { - use futures::stream::StreamExt; - - async_std::stream::interval(self.0) - .map(|_| std::time::Instant::now()) - .boxed() - } - } -}