Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
GIPS - General Inter-Process Solution
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.
Features
- 🚀 High Performance: Zero-copy shared memory and efficient message passing
- 🔒 Secure by Default: Built-in credential verification and access control policies
- 🌍 Cross-Platform: Unified API across Linux, macOS, and Windows
- ⚡ Event-Driven: Efficient polling mechanism for scalable IPC servers
- 🛡️ Type-Safe: Rust's type system ensures memory safety and prevents common IPC bugs
- 📦 Flexible: Support for various data transfer methods including messages and shared memory
Platform Support
| 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 |
Core Components
IPC (gips::ipc)
Provides cross-platform IPC primitives for message passing:
- Listener: Server-side endpoint that accepts incoming connections
- Endpoint: Client-side connection to a named service
- Connection: Bidirectional communication channel
- Message: Container for payload data and transferable objects
- Policy: Security policies for access control
Polling (gips::poll)
Event-driven I/O multiplexing for scalable IPC servers:
- Poller: Cross-platform event loop for monitoring multiple sources
- Source: Types that can be registered with a poller
- Events: Collection of ready events from the poller
- Interest: Read/write interest flags
Shared Memory (gips::shm)
High-performance shared memory regions:
- Shm: Memory mapped region that can be shared across processes
- Header: Metadata for managing shared memory regions
- Zero-copy data transfer by passing handles via IPC
Quick Start
Add GIPS to your Cargo.toml:
[]
= "0.1"
Basic IPC Example
use ;
// Server
// Client
Event-Driven Server
use Listener;
use ;
use Duration;
let mut poller = new?;
let mut listener = bind?;
let token = poller.register?;
let mut events = with_capacity;
loop
Shared Memory Transfer
use Shm;
use ;
// Create and share memory
let shm = new?;
shm.write;
let shm_handle = try_from?;
endpoint.send?;
// Receive and access shared memory
let message = endpoint.recv?;
let shm_object = message.objects.into_iter.next.unwrap;
let shm = try_from?;
let data = shm.read;
println!;
Security
GIPS provides built-in security features for IPC:
Access Control Policies
use ;
// Require elevated privileges
let descriptor = new
.require_privileged;
// Restrict to specific users
let descriptor = new
.with_allowed_uid;
// Restrict to specific groups
let descriptor = new
.with_allowed_group;
// Custom validation
let descriptor = new
.with_credential_validator;
let mut listener = bind?;
Credential Inspection
let pod = listener.accept?;
let credentials = pod.credentials;
println!;
println!;
println!;
println!;
println!;
Examples
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 memory
Run examples with:
Architecture
GIPS uses platform-specific backends while providing a unified API:
Linux Implementation
- IPC: Unix domain sockets with
SOCK_SEQPACKETfor message boundaries - Polling: Linux
epollfor efficient event notification - Shared Memory: POSIX shared memory (
shm_open/mmap) - Credentials:
SO_PEERCREDsocket option for peer authentication
macOS Implementation
- IPC: Mach ports via Bootstrap Server for service registration
- Polling: kqueue for event notification
- Shared Memory: Mach memory objects transferred via port rights
- Credentials: Audit tokens from Mach message trailers
Windows Implementation
- IPC: Named pipes with message mode
- Polling: I/O Completion Ports (IOCP)
- Shared Memory: File mapping objects transferred via handle duplication
- Credentials: Token information from impersonation
Performance Considerations
- Zero-Copy: Shared memory avoids data copying between processes
- Message Boundaries: Built-in message framing eliminates custom protocols
- Efficient Polling: Platform-native event mechanisms scale to thousands of connections
- Minimal Allocations: Reusable event buffers and pre-allocated message space
Logging
GIPS supports both log and tracing crates:
# Use log
= { = "0.1", = ["log"], = false }
# Use tracing (default)
= { = "0.1", = ["tracing"], = false }
Platform Notes
macOS
- Service names should follow reverse-DNS notation:
com.company.service - Bootstrap services persist for the user session
- Requires proper entitlements for production apps
Linux
- Socket paths are created in abstract namespace by default
- Consider using systemd socket activation for services
- File descriptors can be passed through messages
Windows
- Pipe names follow the format
\\.\pipe\{name} - Named pipes support both byte and message modes
- Requires appropriate privileges for global pipes
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
License
This project is licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE-2.0 or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Acknowledgments
GIPS builds upon the excellent work of many platform-specific libraries and draws inspiration from various IPC implementations across the Rust ecosystem.