async_compatibility_layer/art/
async-std.rs1use async_std::prelude::FutureExt;
2pub use async_std::{
3 io::{ReadExt as AsyncReadExt, WriteExt as AsyncWriteExt},
4 main as async_main,
5 net::TcpStream,
6 task::{
7 block_on as async_block_on, block_on as async_block_on_with_runtime, sleep as async_sleep,
8 spawn as async_spawn, spawn_local as async_spawn_local, yield_now as async_yield_now,
9 },
10 test as async_test,
11};
12use std::future::Future;
13use std::time::Duration;
14pub mod stream {
16 pub mod to {
18 pub use async_std::stream::Timeout;
19 }
20}
21pub mod future {
23 pub mod to {
25 pub use async_std::future::TimeoutError;
26 pub type Result<T> = std::result::Result<T, async_std::future::TimeoutError>;
28 }
29}
30
31pub fn async_timeout<T>(
33 duration: Duration,
34 future: T,
35) -> impl Future<Output = Result<T::Output, async_std::future::TimeoutError>>
36where
37 T: Future,
38{
39 future.timeout(duration)
40}
41
42#[must_use]
44pub fn split_stream(stream: TcpStream) -> (TcpStream, TcpStream) {
45 (stream.clone(), stream)
46}