pub struct DtactUnixListener { /* private fields */ }Expand description
A lock-free, non-blocking Unix-domain-socket listener registered with
the dtact-io driver. Mirrors DtactTcpListener’s API.
Implementations§
Source§impl DtactUnixListener
impl DtactUnixListener
Sourcepub fn bind(path: impl AsRef<Path>) -> Result<Self>
pub fn bind(path: impl AsRef<Path>) -> Result<Self>
Bind a new listener to the filesystem path path and register it
with the driver. path must not already exist — like
std::os::unix::net::UnixListener::bind, this does not remove a
stale socket file left behind by a previous run.
§Errors
Returns an io::Error if the underlying bind(2) fails (e.g.
AddrInUse if path already exists) or registration fails.
Sourcepub fn from_std(listener: UnixListener) -> Result<Self>
pub fn from_std(listener: UnixListener) -> Result<Self>
Register an existing non-blocking UnixListener with the dtact-io
driver (see DtactTcpListener::from_std for the mechanics).
§Errors
Returns an io::Error if set_nonblocking fails.
§Panics
Panics if called before init_runtime/init has been called
(WORKERS not yet initialized).
Sourcepub async fn accept(&self) -> Result<(DtactUnixStream, SocketAddr)>
pub async fn accept(&self) -> Result<(DtactUnixStream, SocketAddr)>
Accept a new connection, registering the accepted stream with the dtact-io driver.
Unlike DtactTcpListener::accept, the peer address is fetched
via a getpeername-equivalent (UnixStream::peer_addr) rather
than hand-decoded from the raw accept(2)/io_uring result —
Unix domain socket peer addresses are frequently unnamed (a client
that didn’t bind() before connect(), the common case), so
there’s no meaningful “avoid an extra syscall” win to chase here
the way there is for TCP’s always-populated IP/port.
§Errors
Returns an io::Error if the underlying accept(2)/io_uring
accept completion reports one, or if registering the new stream
with the driver fails.