ocpp_client/runtime/
tokio.rs1use crate::runtime::{Executor, Timer};
5use alloc::boxed::Box;
6use core::future::Future;
7use core::pin::Pin;
8use core::time::Duration;
9
10#[derive(Debug, Clone, Copy, Default)]
12pub struct TokioExecutor;
13
14impl Executor for TokioExecutor {
15 fn spawn(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>) {
16 tokio::spawn(future);
17 }
18}
19
20#[derive(Debug, Clone, Copy, Default)]
22pub struct TokioTimer;
23
24impl Timer for TokioTimer {
25 fn delay<'a>(&'a self, duration: Duration) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>> {
26 Box::pin(tokio::time::sleep(duration))
27 }
28}