feat(client): expose connect types without proto feature (#2377)
				
					
				
			Make it possible to refer to Connected, Connection, HttpConnector, etc. without enabling either of the http1/http2 features. This makes feature selection work better for downstream libraries like hyper-openssl, which don't want to commit to any particular protocol. Fix #2376.
This commit is contained in:
		
							
								
								
									
										1233
									
								
								src/client/client.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1233
									
								
								src/client/client.rs
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -27,6 +27,7 @@ use super::{Connected, Connection}; | |||||||
| /// | /// | ||||||
| /// Sets the [`HttpInfo`](HttpInfo) value on responses, which includes | /// Sets the [`HttpInfo`](HttpInfo) value on responses, which includes | ||||||
| /// transport information such as the remote socket address used. | /// transport information such as the remote socket address used. | ||||||
|  | #[cfg_attr(docsrs, doc(cfg(feature = "tcp")))] | ||||||
| #[derive(Clone)] | #[derive(Clone)] | ||||||
| pub struct HttpConnector<R = GaiResolver> { | pub struct HttpConnector<R = GaiResolver> { | ||||||
|     config: Arc<Config>, |     config: Arc<Config>, | ||||||
|   | |||||||
| @@ -83,13 +83,20 @@ use std::fmt; | |||||||
|  |  | ||||||
| use ::http::Extensions; | use ::http::Extensions; | ||||||
|  |  | ||||||
| #[cfg(feature = "tcp")] | cfg_feature! { | ||||||
| pub mod dns; |     #![feature = "tcp"] | ||||||
| #[cfg(feature = "tcp")] |  | ||||||
| mod http; |     pub use self::http::{HttpConnector, HttpInfo}; | ||||||
| #[cfg(feature = "tcp")] |  | ||||||
| pub use self::http::{HttpConnector, HttpInfo}; |     pub mod dns; | ||||||
| pub use self::sealed::Connect; |     mod http; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | cfg_feature! { | ||||||
|  |     #![any(feature = "http1", feature = "http2")] | ||||||
|  |  | ||||||
|  |     pub use self::sealed::Connect; | ||||||
|  | } | ||||||
|  |  | ||||||
| /// Describes a type returned by a connector. | /// Describes a type returned by a connector. | ||||||
| pub trait Connection { | pub trait Connection { | ||||||
| @@ -260,6 +267,7 @@ where | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #[cfg(any(feature = "http1", feature = "http2"))] | ||||||
| pub(super) mod sealed { | pub(super) mod sealed { | ||||||
|     use std::error::Error as StdError; |     use std::error::Error as StdError; | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										1241
									
								
								src/client/mod.rs
									
									
									
									
									
								
							
							
						
						
									
										1241
									
								
								src/client/mod.rs
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -10,7 +10,7 @@ use futures_channel::oneshot; | |||||||
| #[cfg(feature = "runtime")] | #[cfg(feature = "runtime")] | ||||||
| use tokio::time::{Duration, Instant, Interval}; | use tokio::time::{Duration, Instant, Interval}; | ||||||
|  |  | ||||||
| use super::Ver; | use super::client::Ver; | ||||||
| use crate::common::{task, exec::Exec, Future, Pin, Poll, Unpin}; | use crate::common::{task, exec::Exec, Future, Pin, Poll, Unpin}; | ||||||
|  |  | ||||||
| // FIXME: allow() required due to `impl Trait` leaking types to this lint | // FIXME: allow() required due to `impl Trait` leaking types to this lint | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/lib.rs
									
									
									
									
									
								
							| @@ -58,7 +58,11 @@ | |||||||
|  |  | ||||||
| #[doc(hidden)] | #[doc(hidden)] | ||||||
| pub use http; | pub use http; | ||||||
| #[cfg(any(feature = "http1", feature = "http2"))] | #[cfg(any( | ||||||
|  |     feature = "http1", | ||||||
|  |     feature = "http2", | ||||||
|  |     all(feature = "client", feature = "tcp") | ||||||
|  | ))] | ||||||
| #[macro_use] | #[macro_use] | ||||||
| extern crate tracing; | extern crate tracing; | ||||||
|  |  | ||||||
| @@ -89,9 +93,11 @@ cfg_proto! { | |||||||
| } | } | ||||||
|  |  | ||||||
| cfg_feature! { | cfg_feature! { | ||||||
|     #![all(feature = "client", any(feature = "http1", feature = "http2"))] |     #![all(feature = "client")] | ||||||
|  |  | ||||||
|     pub mod client; |     pub mod client; | ||||||
|  |     #[cfg(any(feature = "http1", feature = "http2"))] | ||||||
|  |     #[doc(no_inline)] | ||||||
|     pub use crate::client::Client; |     pub use crate::client::Client; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -91,6 +91,7 @@ where | |||||||
|         self.read_buf_strategy = ReadStrategy::Exact(sz); |         self.read_buf_strategy = ReadStrategy::Exact(sz); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     #[cfg(feature = "server")] | ||||||
|     pub fn set_write_strategy_flatten(&mut self) { |     pub fn set_write_strategy_flatten(&mut self) { | ||||||
|         // this should always be called only at construction time, |         // this should always be called only at construction time, | ||||||
|         // so this assert is here to catch myself |         // so this assert is here to catch myself | ||||||
| @@ -475,6 +476,7 @@ impl<B> WriteBuf<B> | |||||||
| where | where | ||||||
|     B: Buf, |     B: Buf, | ||||||
| { | { | ||||||
|  |     #[cfg(feature = "server")] | ||||||
|     fn set_strategy(&mut self, strategy: WriteStrategy) { |     fn set_strategy(&mut self, strategy: WriteStrategy) { | ||||||
|         self.strategy = strategy; |         self.strategy = strategy; | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user