1use core::future::Future;
2use core::pin::Pin;
3use core::task::{Context, Poll};
45/// Internal helper struct to assert that a future is send.
6#[pin_project::pin_project]
7pub(crate) struct AssertSend<T>(#[pin] T);
89impl<T> AssertSend<T> {
10/// Assert that the given inner value is `Send` by some external invariant.
11 ///
12 /// # Safety
13 ///
14 /// ProtocolCaller must assert that nothing is done with inner that violates it
15 /// being `Send` at runtime.
16pub(crate) unsafe fn new(inner: T) -> Self {
17Self(inner)
18 }
19}
2021// Safety: we wrap all APIs around the [VmExecution], preventing values from
22// escaping from contained virtual machine.
23unsafe impl<T> Send for AssertSend<T> {}
2425impl<T> Future for AssertSend<T>
26where
27T: Future,
28{
29type Output = T::Output;
3031fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
32let this = self.project();
33 this.0.poll(cx)
34 }
35}