Skip to main content

DtactUnixListener

Struct DtactUnixListener 

Source
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

Source

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.

Source

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).

Source

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.

Trait Implementations§

Source§

impl Drop for DtactUnixListener

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.