1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use crate::Runtime;
use std::future::Future;
use std::pin::Pin;
use mockall::mock;
mod gen {
#![allow(missing_docs)]
use super::{mock, Future, Pin};
mock! {
pub Runtime {
fn mock_workaround_spawn<O: 'static>(&self, future: Pin<Box<dyn Future<Output = O> + Send + 'static>>) {}
}
trait Clone {
fn clone(&self) -> Self;
}
}
}
pub use gen::*;
impl std::fmt::Debug for MockRuntime {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MockRuntime").finish()
}
}
impl Runtime for MockRuntime {
fn spawn<F>(&self, future: F)
where
F: Future<Output = ()> + Send + 'static,
{
self.mock_workaround_spawn(Box::pin(future))
}
}