1use crate::{Error, Relay};
2use std::pin::Pin;
3use std::task::{Context, Poll};
4
5pub trait RelayExt: Relay {
6 fn run(&mut self) -> Run<'_, Self> {
7 Run { r: self }
8 }
9}
10
11impl<R: Relay + ?Sized> RelayExt for R {}
12
13pub struct Run<'a, R: Relay + ?Sized> {
14 r: &'a mut R,
15}
16
17impl<'a, S: Relay + ?Sized> Future for Run<'a, S> {
18 type Output = Result<(), Error>;
19
20 fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
21 let r = unsafe { self.map_unchecked_mut(|s| s.r) };
22 r.poll_run(cx)
23 }
24}