Expand description
Cross-platform local IPC for roam.
This crate provides a unified API for local inter-process communication:
- Unix: Uses Unix domain sockets
- Windows: Uses named pipes
§Usage
§Server
ⓘ
use roam_local::LocalListener;
// On Unix: path like "/tmp/my-app.sock"
// On Windows: pipe name like r"\\.\pipe\my-app"
let mut listener = LocalListener::bind(endpoint)?;
loop {
let stream = listener.accept().await?;
// stream implements AsyncRead + AsyncWrite
tokio::spawn(handle_connection(stream));
}§Client
ⓘ
use roam_local::connect;
let stream = connect(endpoint).await?;
// stream implements AsyncRead + AsyncWrite§Platform Differences
The main API is the same across platforms, but there are some differences:
- Endpoint format: Unix uses filesystem paths, Windows uses pipe names
(e.g.,
\\.\pipe\my-app) - Stream types: On Unix, both client and server use
UnixStream. On Windows, the client usesNamedPipeClientand the server usesNamedPipeServer. Both implementAsyncRead + AsyncWrite. - Cleanup: Unix sockets leave files that may need manual cleanup. Windows named pipes are automatically cleaned up when all handles close.
Structs§
- Local
Listener - A local IPC listener (Unix socket listener on Unix platforms).
Functions§
- connect
- Connect to a local IPC endpoint.
- endpoint_
exists - Check if a local IPC endpoint exists.
- path_
to_ pipe_ name - On Unix, this just returns the path as a string. Provided for API compatibility when writing cross-platform code.
- remove_
endpoint - Remove a local IPC endpoint.
Type Aliases§
- Local
Stream - A local IPC stream (Unix socket on Unix platforms).