Skip to main content

MaybeTlsSettings

Type Alias MaybeTlsSettings 

Source
pub type MaybeTlsSettings = MaybeTls<(), TlsSettings>;

Aliased Type§

pub enum MaybeTlsSettings {
    Raw(()),
    Tls(TlsSettings),
}

Variants§

Implementations§

Source§

impl MaybeTlsSettings

Source

pub async fn bind(&self, addr: &SocketAddr) -> Result<MaybeTlsListener>

Source

pub async fn bind_with_allowlist( &self, addr: &SocketAddr, allow_origin: Vec<IpNet>, ) -> Result<MaybeTlsListener>

Source

pub async fn bind_reloadable( &self, addr: &SocketAddr, reloader: Option<TlsAcceptorReloader>, ) -> Result<MaybeTlsListener>

Bind a listener, optionally sharing a TlsAcceptorReloader so its acceptor can be swapped at runtime. When reloader is Some and TLS is enabled, connections accepted by the returned listener use the acceptor the reloader currently holds; otherwise the acceptor is fixed for the lifetime of the listener.

Source§

impl MaybeTlsSettings

Source

pub async fn connect( &self, host: &str, addr: &SocketAddr, ) -> Result<MaybeTlsStream<TcpStream>>

Source§

impl MaybeTlsSettings

Source

pub fn reloadable_acceptor(&self) -> Result<Option<TlsAcceptorReloader>>

Build a reloadable acceptor handle for server use, or None when TLS is disabled.

Pass the returned handle to bind_reloadable so the bound listener serves it, and keep a clone to call reload when the certificate material rotates.

Source§

impl MaybeTlsSettings

Source

pub fn enable_client() -> Result<Self>

Source

pub fn tls_client(config: Option<&TlsConfig>) -> Result<Self>

Source

pub fn from_config( config: Option<&TlsEnableableConfig>, for_server: bool, ) -> Result<Self>

Generate an optional settings struct from the given optional configuration reference. If config is None, TLS is disabled. The for_server parameter indicates the options should be interpreted as being for a TLS server, which requires an identity certificate and changes the certificate verification default to false.

Source

pub const fn http_protocol_name(&self) -> &'static str

Trait Implementations§

Source§

impl From<TlsSettings> for MaybeTlsSettings

Source§

fn from(tls: TlsSettings) -> Self

Converts to this type from the input type.