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
				
			| @@ -376,6 +376,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> { | ||||
|         match self.inner.as_mut().expect("already upgraded") { | ||||
|             &mut Either::A(ref mut h1) => { | ||||
| @@ -386,6 +390,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<T>, 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()) | ||||
|         }) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl<T, B> Future for Connection<T, B> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user