| Crates.io | gips |
| lib.rs | gips |
| version | 0.2.0 |
| created_at | 2025-11-26 14:51:18.329606+00 |
| updated_at | 2025-12-06 14:27:47.187605+00 |
| description | General inter-process solution |
| homepage | |
| repository | https://github.com/funelk/gips |
| max_upload_size | |
| id | 1951487 |
| size | 330,886 |
A high-performance, cross-platform inter-process solution library for Rust. GIPS currently provides unified abstractions for IPC/SHM/POLL primitives across Linux, macOS, and Windows, with a focus on performance, security, and ease of use.
| Platform | IPC Backend | Polling | Shared Memory |
|---|---|---|---|
| Linux | Unix Domain Sockets (SOCK_SEQPACKET) | epoll | POSIX shm |
| macOS | Mach Ports | kqueue | Mach memory objects |
| Windows | Named Pipes | IOCP | File mapping |
gips::ipc)Provides cross-platform IPC primitives for message passing:
gips::poll)Event-driven I/O multiplexing for scalable IPC servers:
gips::shm)High-performance shared memory regions:
Add GIPS to your Cargo.toml:
[dependencies]
gips = "0.1"
use gips::ipc::{Listener, Endpoint};
// Server
fn server() -> std::io::Result<()> {
let mut listener = Listener::bind("com.example.myservice")?;
let pod = listener.accept()?;
let (connection, message) = pod.split();
println!("Received: {}", String::from_utf8_lossy(&message.payload));
connection.reply(b"Hello from server!", &[])?;
Ok(())
}
// Client
fn client() -> std::io::Result<()> {
let mut endpoint = Endpoint::connect("com.example.myservice")?;
endpoint.send(b"Hello from client!", &[])?;
let response = endpoint.recv()?;
println!("Received: {}", String::from_utf8_lossy(&response.payload));
Ok(())
}
use gips::ipc::Listener;
use gips::poll::{Poller, Events, Interest};
use std::time::Duration;
let mut poller = Poller::new()?;
let mut listener = Listener::bind("com.example.myservice")?;
let token = poller.register(&mut listener, Interest::READABLE)?;
let mut events = Events::with_capacity(128);
loop {
poller.poll(&mut events, Some(Duration::from_secs(1)))?;
for event in &events {
if event.token() == token && event.is_readable() {
let pod = listener.accept()?;
// Handle connection...
}
}
}
use gips::shm::Shm;
use gips::ipc::{Endpoint, Object};
// Create and share memory
let shm = Shm::new(None::<String>, 4096)?;
shm.write(b"Shared data", 0);
let shm_handle = Object::try_from(&shm)?;
endpoint.send(b"shm", &[shm_handle])?;
// Receive and access shared memory
let message = endpoint.recv()?;
let shm_object = message.objects.into_iter().next().unwrap();
let shm = Shm::try_from(shm_object)?;
let data = shm.read(0, Some(100));
println!("Shared data: {}", String::from_utf8_lossy(data));
GIPS provides built-in security features for IPC:
use gips::ipc::{ServiceDescriptor, Policy};
// Require elevated privileges
let descriptor = ServiceDescriptor::new("com.example.secure")
.require_privileged();
// Restrict to specific users
let descriptor = ServiceDescriptor::new("com.example.useronly")
.with_allowed_uid(["1000", "1001"]);
// Restrict to specific groups
let descriptor = ServiceDescriptor::new("com.example.grouponly")
.with_allowed_group(["admin", "staff"]);
// Custom validation
let descriptor = ServiceDescriptor::new("com.example.custom")
.with_credential_validator(|creds| {
if creds.pid < 1000 {
return Err(std::io::Error::new(
std::io::ErrorKind::PermissionDenied,
"PID too low"
));
}
Ok(())
});
let mut listener = Listener::bind(descriptor)?;
let pod = listener.accept()?;
let credentials = pod.credentials();
println!("Connected process:");
println!(" PID: {}", credentials.pid);
println!(" UID: {}", credentials.uid);
println!(" Groups: {:?}", credentials.gid_list);
println!(" Privileged: {}", credentials.is_privileged);
The examples/ directory contains complete working examples:
ipc.rs: Simple echo server demonstrating basic IPCpoll.rs: Event-driven server handling multiple connectionsshm.rs: Producer-consumer pattern using shared memoryRun examples with:
cargo run --example ipc
cargo run --example poll
cargo run --example shm
GIPS uses platform-specific backends while providing a unified API:
SOCK_SEQPACKET for message boundariesepoll for efficient event notificationshm_open/mmap)SO_PEERCRED socket option for peer authenticationGIPS supports both log and tracing crates:
# Use log
gips = { version = "0.1", features = ["log"], default-features = false }
# Use tracing (default)
gips = { version = "0.1", features = ["tracing"], default-features = false }
com.company.service\\.\pipe\{name}Contributions are welcome! Please feel free to submit issues and pull requests.
This project is licensed under either of:
at your option.
GIPS builds upon the excellent work of many platform-specific libraries and draws inspiration from various IPC implementations across the Rust ecosystem.