hyper_rustls

Struct HttpsConnectorBuilder

Source
pub struct HttpsConnectorBuilder<State>(/* private fields */);
Expand description

A builder for an HttpsConnector

This makes configuration flexible and explicit and ensures connector features match crate features

§Examples

use hyper_rustls::HttpsConnectorBuilder;

    let https = HttpsConnectorBuilder::new()
    .with_webpki_roots()
    .https_only()
    .enable_http1()
    .build();

Implementations§

Source§

impl ConnectorBuilder<WantsTlsConfig>

Source

pub fn new() -> Self

Creates a new ConnectorBuilder

Source

pub fn with_tls_config( self, config: ClientConfig, ) -> ConnectorBuilder<WantsSchemes>

Passes a rustls ClientConfig to configure the TLS connection

The alpn_protocols field is required to be empty (or the function will panic) and will be rewritten to match the enabled schemes (see enable_http1, enable_http2) before the connector is built.

Source

pub fn with_webpki_roots(self) -> ConnectorBuilder<WantsSchemes>

Shorthand for using rustls’ default crypto provider and its safe defaults.

See ConfigBuilderExt::with_webpki_roots

Source

pub fn with_provider_and_webpki_roots( self, provider: impl Into<Arc<CryptoProvider>>, ) -> Result<ConnectorBuilder<WantsSchemes>, Error>

Shorthand for using a custom CryptoProvider, Rustls’ safe default protocol versions and Mozilla roots

See ConfigBuilderExt::with_webpki_roots

Source§

impl ConnectorBuilder<WantsSchemes>

Source

pub fn https_only(self) -> ConnectorBuilder<WantsProtocols1>

Enforce the use of HTTPS when connecting

Only URLs using the HTTPS scheme will be connectable.

Source

pub fn https_or_http(self) -> ConnectorBuilder<WantsProtocols1>

Allow both HTTPS and HTTP when connecting

HTTPS URLs will be handled through rustls, HTTP URLs will be handled by the lower-level connector.

Source§

impl ConnectorBuilder<WantsProtocols1>

Source

pub fn enable_http1(self) -> ConnectorBuilder<WantsProtocols2>

Enable HTTP1

This needs to be called explicitly, no protocol is enabled by default

Source

pub fn with_server_name_resolver( self, resolver: impl ResolveServerName + 'static + Sync + Send, ) -> Self

Override server name for the TLS stack

By default, for each connection hyper-rustls will extract host portion of the destination URL and verify that server certificate contains this value.

If this method is called, hyper-rustls will instead use this resolver to compute the value used to verify the server certificate.

Source

pub fn with_server_name(self, override_server_name: String) -> Self

👎Deprecated since 0.27.1: use Self::with_server_name_resolver with FixedServerNameResolver instead

Override server name for the TLS stack

By default, for each connection hyper-rustls will extract host portion of the destination URL and verify that server certificate contains this value.

If this method is called, hyper-rustls will instead verify that server certificate contains override_server_name. Domain name included in the URL will not affect certificate validation.

Source§

impl ConnectorBuilder<WantsProtocols2>

Source

pub fn build(self) -> HttpsConnector<HttpConnector>

This builds an HttpsConnector built on hyper’s default HttpConnector

Source

pub fn wrap_connector<H>(self, conn: H) -> HttpsConnector<H>

This wraps an arbitrary low-level connector into an HttpsConnector

Trait Implementations§

Source§

impl Default for ConnectorBuilder<WantsTlsConfig>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<State> Freeze for ConnectorBuilder<State>
where State: Freeze,

§

impl<State> RefUnwindSafe for ConnectorBuilder<State>
where State: RefUnwindSafe,

§

impl<State> Send for ConnectorBuilder<State>
where State: Send,

§

impl<State> Sync for ConnectorBuilder<State>
where State: Sync,

§

impl<State> Unpin for ConnectorBuilder<State>
where State: Unpin,

§

impl<State> UnwindSafe for ConnectorBuilder<State>
where State: UnwindSafe,

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, 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