pub struct IpcClient { /* private fields */ }Expand description
Client for communicating with a running super::IpcServer.
Uses Unix domain sockets on Linux/macOS and named pipes on Windows. Each method opens a fresh connection for the duration of the call.
§Examples
let client = IpcClient::default();
if client.is_running().await {
let response = client.send(IpcRequest::List).await?;
println!("{response:?}");
}Implementations§
Source§impl IpcClient
impl IpcClient
Sourcepub fn with_path(path: impl Into<String>) -> Self
pub fn with_path(path: impl Into<String>) -> Self
Create a client targeting a custom socket path.
Prefer IpcClient::default in production code.
This method exists primarily for test isolation.
Sourcepub async fn is_running(&self) -> bool
pub async fn is_running(&self) -> bool
Return true if a daemon is reachable on the configured socket.
This is a lightweight connection probe — no request is sent.
Sourcepub async fn send(&self, request: IpcRequest) -> Result<IpcResponse>
pub async fn send(&self, request: IpcRequest) -> Result<IpcResponse>
Send a single request to the daemon and await its response.
Opens a connection, writes the request as a newline-terminated JSON object, reads one response line, then closes the connection.
§Errors
Returns IpcError if the connection fails, the daemon is not running,
or serialization of the request or response fails.
Sourcepub async fn subscribe(&self) -> Result<Receiver<DnsEvent>>
pub async fn subscribe(&self) -> Result<Receiver<DnsEvent>>
Subscribe to daemon events and receive them through an async channel.
Connects to the daemon, sends a IpcRequest::Subscribe command, and
immediately returns a mpsc::Receiver that yields DnsEvent values
as they arrive. The background task exits when the connection is closed.
Dropping the returned receiver causes the background task to exit on the next event delivery attempt.
§Errors
Returns IpcError if the initial connection or subscribe handshake fails.