use crate::runtime::{Executor, Timer};
use alloc::boxed::Box;
use core::future::Future;
use core::pin::Pin;
use core::time::Duration;
#[derive(Debug, Clone, Copy, Default)]
pub struct TokioExecutor;
impl Executor for TokioExecutor {
fn spawn(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>) {
tokio::spawn(future);
}
}
#[derive(Debug, Clone, Copy, Default)]
pub struct TokioTimer;
impl Timer for TokioTimer {
fn delay<'a>(&'a self, duration: Duration) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>> {
Box::pin(tokio::time::sleep(duration))
}
}