use crate::{event, inet::datagram, path};
use core::task::{Context, Poll};
pub mod pair;
pub trait Rx: Sized {
type PathHandle;
type Queue: Queue<Handle = Self::PathHandle>;
type Error;
#[inline]
fn ready(&mut self) -> RxReady<'_, Self> {
RxReady(self)
}
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>>;
fn queue<F: FnOnce(&mut Self::Queue)>(&mut self, f: F);
fn handle_error<E: event::EndpointPublisher>(self, error: Self::Error, event: &mut E);
}
impl_ready_future!(Rx, RxReady, Result<(), T::Error>);
pub trait RxExt: Rx {
#[inline]
fn with_pair<Other>(self, other: Other) -> pair::Channel<Self, Other>
where
Other: Rx<PathHandle = Self::PathHandle>,
{
pair::Channel { a: self, b: other }
}
}
impl<R: Rx> RxExt for R {}
pub trait Queue {
type Handle: path::Handle;
fn for_each<F: FnMut(datagram::Header<Self::Handle>, &mut [u8])>(&mut self, on_packet: F);
fn is_empty(&self) -> bool;
}