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
impl SocketListener
Sourcepub fn bind_fresh(
path: impl Into<PathBuf>,
) -> Result<Self, SocketTransportError>
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.
Sourcepub fn bind(path: impl Into<PathBuf>) -> Result<Self, SocketTransportError>
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.
Sourcepub fn try_clone_raw_listener(
&self,
) -> Result<UnixListener, SocketTransportError>
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.
Sourcepub fn accept(&self) -> Result<SocketAcceptedClient, SocketTransportError>
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.