use std::{
future::{Future, Ready},
io,
};
pub trait Accept<I> {
type Stream;
type Future: Future<Output = io::Result<Self::Stream>>;
fn accept(&self, stream: I) -> Self::Future;
}
#[derive(Clone, Copy, Debug, Default)]
pub struct DefaultAcceptor;
impl DefaultAcceptor {
pub fn new() -> Self {
Self
}
}
impl<I> Accept<I> for DefaultAcceptor {
type Stream = I;
type Future = Ready<io::Result<Self::Stream>>;
fn accept(&self, stream: I) -> Self::Future {
std::future::ready(Ok(stream))
}
}