1use crate::net::TcpStream;
2use std::{fmt, io, net};
3
4pub struct Incoming<'a> {
10 std: net::Incoming<'a>,
11}
12
13impl<'a> Incoming<'a> {
14 #[inline]
20 pub fn from_std(std: net::Incoming<'a>) -> Self {
21 Self { std }
22 }
23}
24
25impl<'a> Iterator for Incoming<'a> {
26 type Item = io::Result<TcpStream>;
27
28 #[inline]
29 fn next(&mut self) -> Option<Self::Item> {
30 self.std.next().map(|result| {
31 let tcp_stream = result?;
32 Ok(TcpStream::from_std(tcp_stream))
33 })
34 }
35
36 #[inline]
37 fn size_hint(&self) -> (usize, Option<usize>) {
38 self.std.size_hint()
39 }
40}
41
42impl<'a> fmt::Debug for Incoming<'a> {
43 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44 self.std.fmt(f)
45 }
46}