Expose `async_std::future::TimeoutFuture` just like `async_std::stream::Timeout`
iamazy opened this issue · comments
iamazy commented
I want to wrap async_std::future::TimeoutFuture
in a common executor but it's crate private. Is there any consideration for making it private? My solution for now is using smol-timeout, but I think expose async_std::future::TimeoutFuture
is a better way.
My use case is as follow:
/// a future producing a `()` after some time
#[allow(clippy::large_enum_variant)]
pub enum Timeout<T: Future> {
/// wrapper for tokio's `Timeout`
#[cfg(feature = "tokio-runtime")]
Tokio(tokio::time::Timeout<T>),
/// wrapper for async-std's `Timeout`
#[cfg(feature = "async-std-runtime")]
AsyncStd(async_std::future::TimeoutFuture<T>),
#[cfg(all(not(feature = "tokio-runtime"), not(feature = "async-std-runtime")))]
PlaceHolder,
}
John Nunley commented
I believe that the current accepted solution is to use Timeout
to wrap a pending()
future. This should be a concrete type. If that doesn't work, you can import async-io
directly and use their Timer
type.
iamazy commented
Thanks, I will try to use async-io