Files
tokio/tokio-tcp/src/incoming.rs
T
Carl Lerche d91c775f36 Remove dead futures2 code. (#538)
The futures 0.2 crate is not intended for widespread usage. Also, the
futures team is exploring the compat shim route.

If futures 0.3 support is added to Tokio 0.1, then a different
integration route will be explored, making the current code unhelpful.
2018-08-09 21:56:53 -07:00

31 lines
737 B
Rust

use super::TcpListener;
use super::TcpStream;
use std::io;
use futures::stream::Stream;
use futures::{Poll, Async};
/// Stream returned by the `TcpListener::incoming` function representing the
/// stream of sockets received from a listener.
#[must_use = "streams do nothing unless polled"]
#[derive(Debug)]
pub struct Incoming {
inner: TcpListener,
}
impl Incoming {
pub(crate) fn new(listener: TcpListener) -> Incoming {
Incoming { inner: listener }
}
}
impl Stream for Incoming {
type Item = TcpStream;
type Error = io::Error;
fn poll(&mut self) -> Poll<Option<Self::Item>, io::Error> {
let (socket, _) = try_ready!(self.inner.poll_accept());
Ok(Async::Ready(Some(socket)))
}
}