feat(server): introduce Accept trait
				
					
				
			The `Accept` trait is used by the server types to asynchronously accept
incoming connections. This replaces the previous usage of `Stream`.
BREAKING CHANGE: Passing a `Stream` to `Server::builder` or
  `Http::serve_incoming` must be changed to pass an `Accept` instead. The
  `stream` optional feature can be enabled, and the a stream can be
  converted using `hyper::server:🉑:from_stream`.
			
			
This commit is contained in:
		| @@ -3,7 +3,6 @@ use std::io; | ||||
| use std::net::{SocketAddr, TcpListener as StdTcpListener}; | ||||
| use std::time::Duration; | ||||
|  | ||||
| use futures_core::Stream; | ||||
| use futures_util::FutureExt as _; | ||||
| use tokio_net::driver::Handle; | ||||
| use tokio_net::tcp::TcpListener; | ||||
| @@ -11,6 +10,7 @@ use tokio_timer::Delay; | ||||
|  | ||||
| use crate::common::{Future, Pin, Poll, task}; | ||||
|  | ||||
| use super::Accept; | ||||
| pub use self::addr_stream::AddrStream; | ||||
|  | ||||
| /// A stream of connections from binding to an address. | ||||
| @@ -156,6 +156,7 @@ impl AddrIncoming { | ||||
|     } | ||||
| } | ||||
|  | ||||
| /* | ||||
| impl Stream for AddrIncoming { | ||||
|     type Item = io::Result<AddrStream>; | ||||
|  | ||||
| @@ -164,6 +165,17 @@ impl Stream for AddrIncoming { | ||||
|         Poll::Ready(Some(result)) | ||||
|     } | ||||
| } | ||||
| */ | ||||
|  | ||||
| impl Accept for AddrIncoming { | ||||
|     type Conn = AddrStream; | ||||
|     type Error = io::Error; | ||||
|  | ||||
|     fn poll_accept(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Option<Result<Self::Conn, Self::Error>>> { | ||||
|         let result = ready!(self.poll_next_(cx)); | ||||
|         Poll::Ready(Some(result)) | ||||
|     } | ||||
| } | ||||
|  | ||||
| /// This function defines errors that are per-connection. Which basically | ||||
| /// means that if we get this error from `accept()` system call it means | ||||
|   | ||||
		Reference in New Issue
	
	Block a user