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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use crate::*;
#[must_use]
pub struct GhostChanRespond<T: 'static + Send>(
::futures::channel::oneshot::Sender<(T, ::tracing::Span)>,
&'static str,
);
impl<T: 'static + Send> GhostChanRespond<T> {
#[doc(hidden)]
pub fn new(
sender: ::futures::channel::oneshot::Sender<(T, ::tracing::Span)>,
trace: &'static str,
) -> Self {
Self(sender, trace)
}
pub fn respond(self, t: T) {
let _ = self
.0
.send((t, tracing::debug_span!("respond", "{}", self.1)));
}
pub fn r(self, t: T) {
self.respond(t);
}
}
#[cfg(feature = "unstable")]
impl<T: 'static + Send> std::ops::FnOnce<(T,)> for GhostChanRespond<T> {
type Output = ();
extern "rust-call" fn call_once(self, args: (T,)) -> Self::Output {
self.respond(args.0)
}
}
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()
}
}
#[macro_use]
mod r#macro;
pub use r#macro::*;