Skip to main content

HyperTransportBuilder

Struct HyperTransportBuilder 

Source
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

Source

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();
Source

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 requests
  • https_proxy / HTTPS_PROXY: Proxy for HTTPS requests
  • no_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.com
Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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");
Source

pub fn build_with_connector<C>( self, connector: C, ) -> Result<HyperTransport<ProxyConnector<TimeoutConnector<C>>>, Error>
where C: Service<Uri> + Clone + Send + Sync + 'static, C::Response: Connection + Read + Write + Send + Unpin, C::Future: Send + 'static, C::Error: Into<Box<dyn Error + Send + Sync>>,

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);

Trait Implementations§

Source§

impl Default for HyperTransportBuilder

Source§

fn default() -> HyperTransportBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more