Skip to main content

Crate roam_local

Crate roam_local 

Source
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 uses NamedPipeClient and the server uses NamedPipeServer. Both implement AsyncRead + AsyncWrite.
  • Cleanup: Unix sockets leave files that may need manual cleanup. Windows named pipes are automatically cleaned up when all handles close.

Structs§

LocalListener
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§

LocalStream
A local IPC stream (Unix socket on Unix platforms).