use std::{
error::Error,
task::{Context, Poll},
};
pub trait Sender<T> {
fn send(self, t: T) -> Result<(), T>;
fn closed(&mut self) -> impl Future<Output = ()> {
std::future::poll_fn(|cx| self.poll_closed(cx))
}
fn is_closed(&self) -> bool;
fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()>;
}
pub trait Receiver<T>: Future<Output = Result<T, Self::RecvError>> {
type TryRecvError: Error;
type RecvError: Error;
fn close(&mut self);
fn try_recv(&mut self) -> Result<Option<T>, Self::TryRecvError>;
}
pub trait RuntimeOneshot {
type OneshotSender<T>: Sender<T>;
type OneshotReceiver<T>: Receiver<T>;
fn channel<T>() -> (Self::OneshotSender<T>, Self::OneshotReceiver<T>);
}