cap_std/net/
incoming.rs
use crate::net::TcpStream;
use std::{fmt, io, net};
pub struct Incoming<'a> {
std: net::Incoming<'a>,
}
impl<'a> Incoming<'a> {
#[inline]
pub 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(TcpStream::from_std(tcp_stream))
})
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.std.size_hint()
}
}
impl<'a> fmt::Debug for Incoming<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.std.fmt(f)
}
}