pub trait Listener: Send {
type Acceptor: Acceptor;
fn into_acceptor<'async_trait>(
self
) -> Pin<Box<dyn Future<Output = IoResult<Self::Acceptor>> + Send + 'async_trait>>
where
Self: 'async_trait;
fn combine<T>(self, other: T) -> Combined<Self, T>
where
Self: Sized,
{ ... }
fn rustls<S: IntoTlsConfigStream<RustlsConfig>>(
self,
config_stream: S
) -> RustlsListener<Self, S>
where
Self: Sized,
{ ... }
fn native_tls<S: IntoTlsConfigStream<NativeTlsConfig>>(
self,
config_stream: S
) -> NativeTlsListener<Self, S>
where
Self: Sized,
{ ... }
fn openssl_tls<S: IntoTlsConfigStream<OpensslTlsConfig>>(
self,
config_stream: S
) -> OpensslTlsListener<Self, S>
where
Self: Sized,
{ ... }
fn acme(self, auto_cert: AutoCert) -> AutoCertListener<Self>
where
Self: Sized,
{ ... }
fn boxed(self) -> BoxListener
where
Self: Sized + 'static,
{ ... }
}
Available on crate feature
server
only.Expand description
Represents a listener that can be listens for incoming connections.
Required Associated Types
Required Methods
Provided Methods
sourcefn combine<T>(self, other: T) -> Combined<Self, T>where
Self: Sized,
fn combine<T>(self, other: T) -> Combined<Self, T>where
Self: Sized,
Combine two listeners.
You can call this function multiple times to combine more listeners.
Example
use poem::listener::{Listener, TcpListener};
let listener = TcpListener::bind("127.0.0.1:80").combine(TcpListener::bind("127.0.0.1:81"));
sourcefn rustls<S: IntoTlsConfigStream<RustlsConfig>>(
self,
config_stream: S
) -> RustlsListener<Self, S>where
Self: Sized,
fn rustls<S: IntoTlsConfigStream<RustlsConfig>>(
self,
config_stream: S
) -> RustlsListener<Self, S>where
Self: Sized,
Available on crate feature
rustls
only.Consume this listener and return a new TLS listener with rustls
.
sourcefn native_tls<S: IntoTlsConfigStream<NativeTlsConfig>>(
self,
config_stream: S
) -> NativeTlsListener<Self, S>where
Self: Sized,
fn native_tls<S: IntoTlsConfigStream<NativeTlsConfig>>(
self,
config_stream: S
) -> NativeTlsListener<Self, S>where
Self: Sized,
Available on crate feature
native-tls
only.Consume this listener and return a new TLS listener with native-tls
.
sourcefn openssl_tls<S: IntoTlsConfigStream<OpensslTlsConfig>>(
self,
config_stream: S
) -> OpensslTlsListener<Self, S>where
Self: Sized,
fn openssl_tls<S: IntoTlsConfigStream<OpensslTlsConfig>>(
self,
config_stream: S
) -> OpensslTlsListener<Self, S>where
Self: Sized,
Available on crate feature
openssl-tls
only.Consume this listener and return a new TLS listener with openssl-tls
.
sourcefn acme(self, auto_cert: AutoCert) -> AutoCertListener<Self>where
Self: Sized,
fn acme(self, auto_cert: AutoCert) -> AutoCertListener<Self>where
Self: Sized,
Available on crate feature
acme
only.Consume this listener and return a new ACME listener.
Example
use poem::listener::{
acme::{AutoCert, LETS_ENCRYPT_PRODUCTION},
Listener, TcpListener,
};
let listener = TcpListener::bind("0.0.0.0:443").acme(
AutoCert::builder()
.directory_url(LETS_ENCRYPT_PRODUCTION)
.domain("poem.rs")
.build()
.unwrap(),
);
sourcefn boxed(self) -> BoxListenerwhere
Self: Sized + 'static,
fn boxed(self) -> BoxListenerwhere
Self: Sized + 'static,
Wrap the listener in a Box
.
Implementations on Foreign Types
sourceimpl Listener for Infallible
impl Listener for Infallible
type Acceptor = Infallible
fn into_acceptor<'async_trait>(
self
) -> Pin<Box<dyn Future<Output = IoResult<Self::Acceptor>> + Send + 'async_trait>>where
Self: 'async_trait,
Implementors
sourceimpl<T: AsRef<Path> + Send> Listener for UnixListener<T>
impl<T: AsRef<Path> + Send> Listener for UnixListener<T>
type Acceptor = UnixAcceptor
sourceimpl<T: ToSocketAddrs + Send> Listener for TcpListener<T>
impl<T: ToSocketAddrs + Send> Listener for TcpListener<T>
type Acceptor = TcpAcceptor
sourceimpl<T: Listener> Listener for AutoCertListener<T>
Available on crate feature acme
only.
impl<T: Listener> Listener for AutoCertListener<T>
Available on crate feature
acme
only.