pub struct SocketPeer { /* private fields */ }Expand description
One connected Unix socket peer speaking the protocol.
Each peer owns a bounded background reader thread. Dropping the peer shuts down the stream, drops the receive queue, and joins that reader thread.
Implementations§
Source§impl SocketPeer
impl SocketPeer
Sourcepub fn connect(path: impl Into<PathBuf>) -> Result<Self, SocketTransportError>
pub fn connect(path: impl Into<PathBuf>) -> Result<Self, SocketTransportError>
Connects to an existing Unix socket listener.
§Errors
Returns an error when the Unix socket cannot be connected or cloned for independent reader/writer ownership.
Sourcepub fn connect_with_io_timeout(
path: impl Into<PathBuf>,
timeout: Duration,
) -> Result<Self, SocketTransportError>
pub fn connect_with_io_timeout( path: impl Into<PathBuf>, timeout: Duration, ) -> Result<Self, SocketTransportError>
Connects to an existing Unix socket and bounds subsequent stream I/O.
This is intended for short-lived runtime discovery and control RPCs whose caller owns an absolute deadline. The caller must still bound how long it waits for a complete protocol response.
§Errors
Returns an error when the socket cannot be connected, its I/O timeouts cannot be configured, or it cannot be cloned for split I/O ownership.
Sourcepub fn connect_with_timeouts(
path: impl Into<PathBuf>,
connect_timeout: Duration,
io_timeout: Duration,
) -> Result<Self, SocketTransportError>
pub fn connect_with_timeouts( path: impl Into<PathBuf>, connect_timeout: Duration, io_timeout: Duration, ) -> Result<Self, SocketTransportError>
Connects to an existing Unix socket with separate connect and stream-I/O timeouts.
This supports control RPCs that require fast endpoint discovery but allow an already-connected peer more time to produce a complete response.
§Errors
Returns an error when the socket cannot be connected, its I/O timeouts cannot be configured, or it cannot be cloned for split I/O ownership.
Sourcepub fn send(
&mut self,
message: &HarnessInputMessage,
) -> Result<(), SocketTransportError>
pub fn send( &mut self, message: &HarnessInputMessage, ) -> Result<(), SocketTransportError>
Sends one peer → harness protocol message over the Unix socket.
§Errors
Returns an error when encoding or flushing the message fails.
Sourcepub fn set_write_timeout(
&self,
timeout: Duration,
) -> Result<(), SocketTransportError>
pub fn set_write_timeout( &self, timeout: Duration, ) -> Result<(), SocketTransportError>
Updates the write timeout for the next bounded control-plane operation.
§Errors
Returns an error when the connected stream rejects the timeout update.
Sourcepub fn recv_timeout(
&mut self,
timeout: Duration,
) -> Result<SocketReceive, SocketTransportError>
pub fn recv_timeout( &mut self, timeout: Duration, ) -> Result<SocketReceive, SocketTransportError>
Reads one harness → peer protocol message or an explicit timeout/close outcome.
§Errors
Returns a decode error for malformed or truncated protocol output.