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.