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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use crate::*;
pub type GhostChanRespond<T> = Box<dyn FnOnce(T) -> GhostResult<()> + 'static + Send>;
pub trait GhostChanSend<T: 'static + Send> {
fn ghost_chan_send(&mut self, item: T) -> ::must_future::MustBoxFuture<'_, GhostResult<()>>;
}
impl<T: 'static + Send> GhostChanSend<T> for ::futures::channel::mpsc::Sender<T> {
fn ghost_chan_send(&mut self, item: T) -> ::must_future::MustBoxFuture<'_, GhostResult<()>> {
use ::futures::{future::FutureExt, sink::SinkExt};
let send_fut = self.send(item);
async move {
send_fut.await?;
Ok(())
}
.boxed()
.into()
}
}
pub struct GhostChanItem<I, O> {
pub input: I,
pub respond: GhostChanRespond<O>,
pub span: tracing::Span,
}
impl<I, O> std::fmt::Debug for GhostChanItem<I, O> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "GhostChanItem")
}
}
#[macro_use]
mod ghost_chan_macros;
pub use ghost_chan_macros::*;