use std::task::Poll;
use super::Select;
use super::hang::{Catalog, CatalogExt};
pub trait Stream: kio::MaybeSend + 'static {
type Ext: CatalogExt;
fn poll_next(&mut self, waiter: &kio::Waiter) -> Poll<crate::Result<Option<Catalog<Self::Ext>>>>;
fn next(&mut self) -> impl std::future::Future<Output = crate::Result<Option<Catalog<Self::Ext>>>> + kio::MaybeSend
where
Self: Sized,
{
async move { kio::wait(|waiter| self.poll_next(waiter)).await }
}
fn select(self, selection: crate::select::Broadcast) -> Select<Self>
where
Self: Sized,
{
Select::new(self, selection)
}
}
impl<S: Stream + ?Sized> Stream for Box<S> {
type Ext = S::Ext;
fn poll_next(&mut self, waiter: &kio::Waiter) -> Poll<crate::Result<Option<Catalog<Self::Ext>>>> {
(**self).poll_next(waiter)
}
}