feat(client,server) Add Connection::without_shutdown()
				
					
				
			* Add `server::conn::Connection::without_shutdown` Returns wrapper Future instance which allows to use `poll_without_shutdown` method more ergonomically. * Add `client::conn::Connection::without_shutdown` Returns wrapper Future instance which allows to use `poll_without_shutdown` method more ergonomically. * Improve `poll_without_shutdown` docs Closes #1786
This commit is contained in:
		
				
					committed by
					
						 Sean McArthur
						Sean McArthur
					
				
			
			
				
	
			
			
			
						parent
						
							fc18b680a5
						
					
				
				
					commit
					edf551b55f
				
			| @@ -542,6 +542,10 @@ where | ||||
|     /// upgrade. Once the upgrade is completed, the connection would be "done", | ||||
|     /// but it is not desired to actally shutdown the IO object. Instead you | ||||
|     /// would take it back using `into_parts`. | ||||
|     /// | ||||
|     /// Use [`poll_fn`](https://docs.rs/futures/0.1.25/futures/future/fn.poll_fn.html) | ||||
|     /// and [`try_ready!`](https://docs.rs/futures/0.1.25/futures/macro.try_ready.html) | ||||
|     /// to work with this function; or use the `without_shutdown` wrapper. | ||||
|     pub fn poll_without_shutdown(&mut self) -> Poll<(), ::Error> { | ||||
|         loop { | ||||
|             let polled = match *self.conn.as_mut().unwrap() { | ||||
| @@ -564,6 +568,16 @@ where | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /// Prevent shutdown of the underlying IO object at the end of service the request, | ||||
|     /// instead run `into_parts`. This is a convenience wrapper over `poll_without_shutdown`. | ||||
|     pub fn without_shutdown(self) -> impl Future<Item=Parts<I,S>, Error=::Error> { | ||||
|         let mut conn = Some(self); | ||||
|         ::futures::future::poll_fn(move || -> ::Result<_> { | ||||
|             try_ready!(conn.as_mut().unwrap().poll_without_shutdown()); | ||||
|             Ok(conn.take().unwrap().into_parts().into()) | ||||
|         }) | ||||
|     } | ||||
|  | ||||
|     fn upgrade_h2(&mut self) { | ||||
|         trace!("Trying to upgrade connection to h2"); | ||||
|         let conn = self.conn.take(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user