cap_async_std/os/unix/net/
incoming.rs1use crate::os::unix::net::UnixStream;
2use async_std::io;
3use async_std::os::unix;
4use async_std::stream::Stream;
5use async_std::task::{Context, Poll};
6use std::fmt;
7use std::pin::Pin;
8
9pub struct Incoming<'a> {
16 std: unix::net::Incoming<'a>,
17}
18
19impl<'a> Incoming<'a> {
20 #[inline]
27 pub fn from_std(std: unix::net::Incoming<'a>) -> Self {
28 Self { std }
29 }
30}
31
32impl<'a> Stream for Incoming<'a> {
33 type Item = io::Result<UnixStream>;
34
35 #[inline]
36 fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
37 Stream::poll_next(Pin::new(&mut self.std), cx).map(|poll| {
38 poll.map(|result| {
39 let unix_stream = result?;
40 Ok(UnixStream::from_std(unix_stream))
41 })
42 })
43 }
44
45 #[inline]
46 fn size_hint(&self) -> (usize, Option<usize>) {
47 self.std.size_hint()
48 }
49}
50
51impl<'a> fmt::Debug for Incoming<'a> {
52 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
53 self.std.fmt(f)
54 }
55}