kode-bridge
δΈζ | English
kode-bridge is a modern Rust library designed for cross-platform (macOS, Linux, Windows) IPC HTTP communication. With a unified API, you can easily send HTTP requests via Unix Domain Sockets or Windows Named Pipes, just as simple as using a regular HTTP client.
β¨ Features
- π True Cross-Platform: Automatically detects the platform and uses optimal IPC methods
- Unix/Linux/macOS: Unix Domain Sockets
- Windows: Named Pipes
- π Zero Configuration: Unified
IpcHttpClientAPI, no platform-specific code required - π¦ Auto Serialization: Built-in JSON request and response handling
- β‘ High Performance: Optimized connection management strategies for different platforms
- π§ Easy Integration: Based on interprocess and Tokio async runtime
- π Complete Support: Includes examples, benchmarks, and comprehensive documentation
π Quick Start
Add Dependencies
[]
= "0.1"
= { = "1", = ["full"] }
= "1.0"
Basic Usage
use IpcHttpClient;
use json;
async
Using Environment Variables
Create a .env file:
# Unix systems
CUSTOM_SOCK=/tmp/my_app.sock
# Windows systems (each backslash needs to be escaped by doubling)
CUSTOM_PIPE=\\\\.\\pipe\\\my_app
Then in your code:
use dotenv;
use env;
async
π Examples
Run built-in examples:
# Basic request example
# Large data request example
# Using custom IPC path
CUSTOM_SOCK=/tmp/my.sock CUSTOM_PIPE=\\\\.\\pipe\\my_pipe
π₯ Performance Benchmarks
Run performance benchmarks:
# Run all benchmarks
# View benchmark reports
Benchmarks automatically:
- Detect the running platform
- Use appropriate environment variables (
CUSTOM_SOCKorCUSTOM_PIPE) - Apply platform-specific performance optimization strategies
ποΈ Architecture Design
βββββββββββββββββββββββββββββββββββββββββββ
β IpcHttpClient β
β (Unified Cross-Platform API) β
βββββββββββββββββββββββββββββββββββββββββββ€
β http_client.rs β
β (HTTP Protocol Handler) β
βββββββββββββββββββββββββββββββββββββββββββ€
β interprocess β
β (Cross-Platform IPC Transport) β
βββββββββββββββββββ¬ββββββββββββββββββββββββ€
β Unix Sockets β Windows Pipes β
β (Unix/Linux) β (Windows) β
βββββββββββββββββββ΄ββββββββββββββββββββββββ
Core Components
IpcHttpClient: Unified client interface that automatically adapts to different platformshttp_client: Platform-agnostic HTTP protocol handling with chunked transfer encoding support- Smart Platform Detection: Compile-time automatic selection of optimal IPC implementation
π― Use Cases
- Local Service Communication: Communicate with local processes like Clash, Mihomo, proxy services, etc.
- Microservice Architecture: High-performance inter-process HTTP communication
- System Integration: Replace traditional REST API local calls
- Performance-Critical Applications: Scenarios requiring low-latency local communication
π οΈ Development
Build Project
Run Tests
Generate Documentation
π Resources
- Platform Guide - Detailed cross-platform usage guide
- Examples - Complete example code
- Benchmarks - Performance benchmarks
π€ Contributing
We welcome Issues and Pull Requests!
π License
This project is licensed under the Apache License 2.0.
See the Licence file for details.