rust_p2p_core/async_compat/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
pub mod mpsc;
pub mod net;
pub mod task;
pub mod time;

#[cfg(feature = "use-async-std")]
use std::future::Future;

pub use task::*;

#[cfg(feature = "use-tokio")]
pub use ::tokio::spawn;

#[cfg(feature = "use-async-std")]
use ::async_std::task::JoinHandle;

#[cfg(feature = "use-async-std")]
pub fn spawn<F>(f: F) -> JoinHandle<Result<F::Output, anyhow::Error>>
where
    F: Future + Send + 'static,
    F::Output: Send + 'static,
{
    ::async_std::task::spawn(async move { Ok(f.await) })
}