use std::error::Error;
use futures_lite::Stream;
pub trait Sender<T: 'static>: Clone {
type SendError: Error;
fn is_closed(&self) -> bool;
}
pub trait SenderExt<T: 'static>: Sender<T> {
fn closed(&mut self) -> impl Future<Output = ()>;
fn same_channel(&self, other: &Self) -> bool;
}
pub trait BoundedSender<T: 'static>: Sender<T> {
type TrySendError: Error;
fn send(&mut self, message: T) -> impl Future<Output = Result<(), Self::SendError>>;
fn try_send(&mut self, message: T) -> Result<(), Self::TrySendError>;
}
pub trait Receiver<T: 'static>: Stream<Item = T> {
type TryRecvError: Error;
fn close(&mut self);
fn try_recv(&mut self) -> Result<Option<T>, Self::TryRecvError>;
}
pub trait UnboundedSender<T: 'static>: Sender<T> {
fn send(&self, message: T) -> Result<(), Self::SendError>;
}
pub trait RuntimeMpsc {
type BoundedSender<T: 'static>: BoundedSender<T>;
type BoundedReceiver<T: 'static>: Receiver<T>;
fn bounded_channel<T: 'static>(
buffer: usize,
) -> (Self::BoundedSender<T>, Self::BoundedReceiver<T>);
type UnboundedSender<T: 'static>: UnboundedSender<T>;
type UnboundedReceiver<T: 'static>: Receiver<T>;
fn unbounded_channel<T: 'static>() -> (Self::UnboundedSender<T>, Self::UnboundedReceiver<T>);
}