Remove async-std support (RIP)
This commit is contained in:
parent
57cb14ce38
commit
91996372cb
8 changed files with 13 additions and 104 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
)))]
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
#[cfg(feature = "tokio")]
|
||||
pub mod tokio;
|
||||
|
||||
#[cfg(feature = "async-std")]
|
||||
pub mod async_std;
|
||||
|
||||
#[cfg(feature = "smol")]
|
||||
pub mod smol;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Self, futures::io::Error> {
|
||||
Ok(Self)
|
||||
}
|
||||
|
||||
#[allow(clippy::let_underscore_future)]
|
||||
fn spawn(&self, future: impl Future<Output = ()> + 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<std::time::Instant> {
|
||||
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::<Self>().hash(state);
|
||||
self.0.hash(state);
|
||||
}
|
||||
|
||||
fn stream(
|
||||
self: Box<Self>,
|
||||
_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()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue