1#![allow(incomplete_features)]
2#![feature(async_fn_in_trait)]
3
4use std::future::Future;
5
6pub mod buf;
7
8#[cfg(all(target_os = "linux", feature = "tokio-uring"))]
9pub use tokio_uring;
10
11#[cfg(all(target_os = "linux", feature = "tokio-uring"))]
12mod compat;
13
14#[cfg(feature = "net")]
15pub mod net;
16
17pub mod io;
18
19pub type BufResult<T, B> = (std::io::Result<T>, B);
20
21pub fn spawn<T: Future + 'static>(task: T) -> tokio::task::JoinHandle<T::Output> {
31 tokio::task::spawn_local(task)
32}
33
34#[cfg(all(target_os = "linux", feature = "tokio-uring"))]
36pub fn start<F: Future>(task: F) -> F::Output {
37 tokio_uring::start(task)
38}
39
40#[cfg(not(all(target_os = "linux", feature = "tokio-uring")))]
42pub fn start<F: Future>(task: F) -> F::Output {
43 use tokio::task::LocalSet;
44
45 tokio::runtime::Builder::new_current_thread()
46 .enable_all()
47 .build()
48 .unwrap()
49 .block_on(async move {
50 let local = LocalSet::new();
51 local.run_until(task).await
52 })
53}