pub struct Listener(/* private fields */);Expand description
A description of one listener a server is bound to.
A Conn carries the Listener it arrived on in its state, and a server exposes
the full set on Info at startup, so a runtime-neutral handler can answer both
“what is this server listening on?” and “which listener did this request come from?” — to
announce every binding at launch, say, or to tag a log line with the ingress a request arrived
on.
Cloning is a reference-count bump, so stamping it onto every conn is cheap.
The inner representation is private, so further provenance (e.g. negotiated SNI) can be added in a minor release without a breaking change.
Implementations§
Source§impl Listener
impl Listener
Sourcepub fn new(kind: ListenerKind, secure: bool) -> Self
pub fn new(kind: ListenerKind, secure: bool) -> Self
Construct a Listener from its kind and whether the listener terminates TLS.
Sourcepub fn tcp(addr: SocketAddr, secure: bool) -> Self
pub fn tcp(addr: SocketAddr, secure: bool) -> Self
Construct a TCP Listener.
Sourcepub fn quic(addr: SocketAddr) -> Self
pub fn quic(addr: SocketAddr) -> Self
Construct a QUIC/HTTP3 Listener. QUIC is always TLS.
Sourcepub fn unix(path: Option<PathBuf>, secure: bool) -> Self
pub fn unix(path: Option<PathBuf>, secure: bool) -> Self
Construct a Unix-domain-socket Listener. The path is None for an unnamed or abstract
socket.
Sourcepub fn kind(&self) -> &ListenerKind
pub fn kind(&self) -> &ListenerKind
The kind of listener this describes.
Sourcepub fn is_secure(&self) -> bool
pub fn is_secure(&self) -> bool
Whether this listener terminates TLS. This reflects the listener’s immutable ground truth,
not necessarily the view a client sees: a plaintext listener fronted by a TLS-terminating
proxy reports false. For the (mutable, possibly forwarding-header-derived) per-request
view, see Conn::is_secure.
Sourcepub fn socket_addr(&self) -> Option<SocketAddr>
pub fn socket_addr(&self) -> Option<SocketAddr>
Trait Implementations§
impl Eq for Listener
Source§impl FromIterator<Listener> for Listeners
impl FromIterator<Listener> for Listeners
impl StructuralPartialEq for Listener
Auto Trait Implementations§
impl Freeze for Listener
impl RefUnwindSafe for Listener
impl Send for Listener
impl Sync for Listener
impl Unpin for Listener
impl UnsafeUnpin for Listener
impl UnwindSafe for Listener
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.