Skip to main content

compio_compat\sys/
mod.rs

1use std::{io, ops::Deref, time::Duration};
2
3use compio_runtime::Runtime;
4use mod_use::mod_use;
5
6cfg_select! {
7    windows => {
8        mod_use![windows];
9    }
10    unix => {
11        mod_use![unix];
12    }
13    _ => {
14        compile_error!("Unsupported platform");
15    }
16}
17
18/// Adapter trait for different runtimes.
19#[allow(async_fn_in_trait)]
20pub trait Adapter: Sized + Deref<Target = Runtime> {
21    /// Creates a new adapter with the given runtime.
22    fn new(runtime: Runtime) -> io::Result<Self>;
23
24    /// Waits for the runtime to be ready, with an optional timeout.
25    async fn wait(&self, timeout: Option<Duration>) -> io::Result<()>;
26
27    /// Clears the runtime's state after waiting.
28    fn clear(&self) -> io::Result<()>;
29}