Skip to main content

SocketListener

Struct SocketListener 

Source
pub struct SocketListener { /* private fields */ }
Expand description

Unix socket listener for later-attached protocol clients.

When dropped, a listener removes only the socket path it created and only if that path still refers to the same device/inode recorded after binding.

Implementations§

Source§

impl SocketListener

Source

pub fn bind_fresh( path: impl Into<PathBuf>, ) -> Result<Self, SocketTransportError>

Binds a listener at an absent path without probing or removing anything.

The caller owns parent-directory preparation and any stale-path reclamation under its own stronger coordination boundary.

§Errors

Returns an error when the path already exists, binding fails, or the created socket cannot be inspected.

Source

pub fn bind(path: impl Into<PathBuf>) -> Result<Self, SocketTransportError>

Binds a Unix socket listener at the given path.

Parent directories are created if needed. An inactive stale Unix socket may be removed, but non-socket paths and active listeners are refused. Active-listener detection opens a short-lived connection that can be observed by an already-running daemon. Existing socket paths are treated as stale only when that probe fails with io::ErrorKind::ConnectionRefused; other probe failures return SocketTransportError::ProbeExistingSocket without unlinking the path.

§Errors

Returns an error when directory creation, stale socket cleanup, binding, post-bind socket metadata inspection, non-socket refusal, or active/unverified socket refusal fails or applies.

Source

pub fn path(&self) -> &Path

Returns the filesystem path of the listener socket.

Source

pub fn try_clone_raw_listener( &self, ) -> Result<UnixListener, SocketTransportError>

Clones the raw Unix listener for daemon/internal stream handoff loops.

This is an escape hatch for callers that need to pass accepted raw streams to higher-level server code instead of using Self::accept. The SocketListener still owns identity-checked path cleanup; callers must ensure cloned listeners are shut down before dropping it.

§Errors

Returns an error when the underlying listener cannot be cloned.

Source

pub fn accept(&self) -> Result<SocketAcceptedClient, SocketTransportError>

Accepts one attached client for harness/server-side protocol handling.

The returned client reads HarnessInputMessage values from the peer and writes HarnessOutputMessage values back to it.

§Errors

Returns an error when accepting the Unix stream or cloning it for split reader/writer ownership fails.

Trait Implementations§

Source§

impl Drop for SocketListener

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more