use crate::net::TcpStream;
use std::{io, net};
pub struct Incoming<'a> {
std: net::Incoming<'a>,
}
impl<'a> Incoming<'a> {
#[inline]
pub unsafe fn from_std(std: net::Incoming<'a>) -> Self {
Self { std }
}
}
impl<'a> Iterator for Incoming<'a> {
type Item = io::Result<TcpStream>;
#[inline]
fn next(&mut self) -> Option<Self::Item> {
self.std.next().map(|result| {
let tcp_stream = result?;
Ok(unsafe { TcpStream::from_std(tcp_stream) })
})
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.std.size_hint()
}
}