pub struct HyperTransportBuilder { /* private fields */ }Expand description
Builder for configuring a HyperTransport.
This builder allows you to configure timeouts and choose between HTTP and HTTPS connectors.
§Example
use launchdarkly_sdk_transport::HyperTransport;
use std::time::Duration;
let transport = HyperTransport::builder()
.connect_timeout(Duration::from_secs(10))
.read_timeout(Duration::from_secs(30))
.build_http();Implementations§
Source§impl HyperTransportBuilder
impl HyperTransportBuilder
Sourcepub fn disable_proxy(self) -> Self
pub fn disable_proxy(self) -> Self
Disable proxy support completely.
When this is set, the transport will connect directly to all hosts,
ignoring any proxy environment variables (HTTP_PROXY, HTTPS_PROXY, etc.).
Use this when you need to ensure no proxy is used, even if proxy environment variables are set in the environment.
§Example
use launchdarkly_sdk_transport::HyperTransport;
let transport = HyperTransport::builder()
.disable_proxy()
.build_http();Sourcepub fn auto_proxy(self) -> Self
pub fn auto_proxy(self) -> Self
Configure the transport to automatically detect proxy settings from environment variables.
This is the default behavior if no proxy configuration method is called.
§Environment Variables
The transport checks these variables (lowercase variants take precedence):
http_proxy/HTTP_PROXY: Proxy for HTTP requestshttps_proxy/HTTPS_PROXY: Proxy for HTTPS requestsno_proxy/NO_PROXY: Comma-separated bypass list
§Routing Logic
- If both HTTP_PROXY and HTTPS_PROXY are set, requests are routed based on their scheme
- If only HTTP_PROXY is set, all requests (HTTP and HTTPS) use that proxy
- If only HTTPS_PROXY is set, only HTTPS requests use the proxy
- NO_PROXY hosts bypass the proxy regardless of scheme
§Example
use launchdarkly_sdk_transport::HyperTransport;
// Explicitly enable auto-detection
let transport = HyperTransport::builder()
.auto_proxy()
.build_http();With environment variables:
export HTTP_PROXY=http://proxy.corp.example.com:8080
export NO_PROXY=localhost,127.0.0.1,.internal.example.comSourcepub fn proxy_url(self, proxy_url: String) -> Self
pub fn proxy_url(self, proxy_url: String) -> Self
Configure the transport to use a custom proxy URL for all requests.
When this is set, all requests will route through the specified proxy,
regardless of environment variables or request scheme. This overrides any
HTTP_PROXY or HTTPS_PROXY environment variables.
§URL Format
The proxy URL must include the scheme (http:// or https://) and can optionally
include authentication credentials:
- Without auth:
http://proxy.example.com:8080 - With auth:
http://username:password@proxy.example.com:8080
§Example
use launchdarkly_sdk_transport::HyperTransport;
// Basic proxy
let transport = HyperTransport::builder()
.proxy_url("http://proxy.example.com:8080".to_string())
.build_http();
// Proxy with authentication
let transport = HyperTransport::builder()
.proxy_url("http://user:pass@proxy.example.com:8080".to_string())
.build_http();§Note
Unlike auto_proxy(), this method does not respect the NO_PROXY environment
variable. All requests will use the specified proxy.
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Set a connect timeout for establishing connections
This timeout applies when establishing the TCP connection to the server. There is no connect timeout by default.
Sourcepub fn read_timeout(self, timeout: Duration) -> Self
pub fn read_timeout(self, timeout: Duration) -> Self
Set a read timeout for reading from connections
This timeout applies when reading data from the connection. There is no read timeout by default.
Sourcepub fn write_timeout(self, timeout: Duration) -> Self
pub fn write_timeout(self, timeout: Duration) -> Self
Set a write timeout for writing to connections
This timeout applies when writing data to the connection. There is no write timeout by default.
Sourcepub fn build_http(self) -> Result<HyperTransport, Error>
pub fn build_http(self) -> Result<HyperTransport, Error>
Build with an HTTP connector
Creates a transport that supports HTTP/1 and HTTP/2 over plain HTTP.
Sourcepub fn build_https(
self,
) -> Result<HyperTransport<ProxyConnector<TimeoutConnector<HttpsConnector<HttpConnector>>>>, Error>
pub fn build_https( self, ) -> Result<HyperTransport<ProxyConnector<TimeoutConnector<HttpsConnector<HttpConnector>>>>, Error>
Build with an HTTPS connector using native TLS
Creates a transport that supports HTTP/1 and HTTP/2 over HTTPS using native TLS. The transport can handle both plain HTTP and HTTPS connections.
This method is only available when the native-tls feature is enabled.
For custom TLS configuration (custom CAs, client certificates, etc.), use
build_with_connector with a custom native TLS connector.
§Example
use launchdarkly_sdk_transport::HyperTransport;
use std::time::Duration;
let transport = HyperTransport::builder()
.connect_timeout(Duration::from_secs(10))
.build_https()
.expect("failed to build HTTPS transport");Sourcepub fn build_with_connector<C>(
self,
connector: C,
) -> Result<HyperTransport<ProxyConnector<TimeoutConnector<C>>>, Error>
pub fn build_with_connector<C>( self, connector: C, ) -> Result<HyperTransport<ProxyConnector<TimeoutConnector<C>>>, Error>
Build with a custom connector
This allows you to provide your own connector implementation, which is useful for:
- Custom TLS configuration
- Proxy support
- Connection pooling customization
- Custom DNS resolution
The connector will be automatically wrapped with a TimeoutConnector that applies
the configured timeout settings.
§Example
use launchdarkly_sdk_transport::HyperTransport;
use hyper_util::client::legacy::connect::HttpConnector;
use std::time::Duration;
let mut connector = HttpConnector::new();
// Configure the connector as needed
connector.set_nodelay(true);
let transport = HyperTransport::builder()
.read_timeout(Duration::from_secs(30))
.build_with_connector(connector);