pub struct Listener { /* private fields */ }Expand description
Listens for incoming qmux connections on a Unix domain socket.
Each accepted connection yields the session plus the peer’s PeerCred, so
the caller can enforce a uid/gid/pid allowlist. The socket file is removed on
drop.
Implementations§
Source§impl Listener
impl Listener
Sourcepub async fn bind(path: impl AsRef<Path>) -> Result<Self, Error>
pub async fn bind(path: impl AsRef<Path>) -> Result<Self, Error>
Bind a Unix socket at path, replacing a stale socket file left by a
previous run.
Refuses to unlink the path if it exists and is not a socket, to avoid clobbering an unrelated file.
Sourcepub fn accept_health(&self) -> Health
pub fn accept_health(&self) -> Health
A live handle to this listener’s accept-loop health, for an embedder that
publishes it (see crate::accept).
Sourcepub fn with_accept_health(self, health: Health) -> Self
pub fn with_accept_health(self, health: Health) -> Self
Report into health instead of the one this listener made for itself.
For an owner that has to hand the handle out before the listener exists:
crate::Server binds these lazily (they need a runtime), but an embedder
registering them with a metrics endpoint does so at startup.
Sourcepub fn with_protocols<I, S>(self, protocols: I) -> Self
pub fn with_protocols<I, S>(self, protocols: I) -> Self
Advertise these application protocols (moq ALPNs) for in-band negotiation, in preference order. The first server entry the client also offers wins.
Sourcepub fn set_mode(&self, mode: u32) -> Result<(), Error>
pub fn set_mode(&self, mode: u32) -> Result<(), Error>
Set the socket file’s permission bits (e.g. 0o660).
Sourcepub async fn accept(&self) -> Option<Result<(Session, PeerCred), Error>>
pub async fn accept(&self) -> Option<Result<(Session, PeerCred), Error>>
Accept the next connection, returning the session and the peer’s credentials.
A failed accept(2) is handled here rather than yielded: it is classified,
counted, logged, and paced by accept_health, then
retried, because the caller has no better answer than to ask again. A
per-connection failure is still yielded as Some(Err(..)).
As in crate::tcp, the Option has no None case left to report.