docs.rs failed to build unison-protocol-0.1.0-alpha2
                        
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.
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.
๐ต Unison Protocol
Next-generation type-safe communication protocol framework
๐ Overview
Unison Protocol is a type-safe communication protocol framework based on KDL (KDL Document Language). Leveraging QUIC transport, it supports building fast, secure, and extensible distributed systems.
๐ฏ Key Features
- Type-safe Communication: Automatic code generation from KDL schemas
- Ultra-low Latency: High-speed communication via QUIC (HTTP/3) transport
- Built-in Security: TLS 1.3 encryption with automatic development certificate generation
- CGP (Context-Generic Programming) Support: Extensible handler system
- Async-first: Fully asynchronous implementation based on Tokio
- Bidirectional Streaming: Full-duplex communication via UnisonStream
- Service-oriented: Lifecycle management via high-level Service trait
๐ Quick Start
Installation
[]
 = "0.1.0-alpha1"
 = {  = "1.40",  = ["full"] }
 = "1.0"
 = "1.0"
 = "0.1"
Basic Usage
1. Protocol Definition (KDL)
// schemas/my_service.kdl
protocol "my-service" version="1.0.0" {
    namespace "com.example.myservice"
    service "UserService" {
        method "createUser" {
            request {
                field "name" type="string" required=true
                field "email" type="string" required=true
            }
            response {
                field "id" type="string" required=true
                field "created_at" type="timestamp" required=true
            }
        }
    }
}
2. Server Implementation
use ;
use json;
async 
3. Client Implementation
use ProtocolClient;
use json;
async 
๐๏ธ Architecture
Component Structure
unison-protocol/
โโโ ๐ฏ Core Layer
โ   โโโ parser/          # KDL schema parser
โ   โโโ codegen/        # Code generators (Rust/TypeScript)
โ   โโโ types/          # Basic type definitions
โ
โโโ ๐ Network Layer
โ   โโโ quic/           # QUIC transport implementation
โ   โโโ client/         # Protocol client
โ   โโโ server/         # Protocol server
โ   โโโ service/        # Service abstraction layer
โ
โโโ ๐งฉ Context Layer (CGP)
    โโโ adapter/        # Existing system integration
    โโโ handlers/       # Extensible handlers
    โโโ traits/         # Generic trait definitions
Core Components
1. UnisonStream - Low-level Bidirectional Streaming
2. Service - High-level Service Abstraction
3. CGP Context - Extensible Context
๐ Performance
Benchmark Results
| Metric | QUIC | WebSocket | HTTP/2 | 
|---|---|---|---|
| Latency (p50) | 2.3ms | 5.1ms | 8.2ms | 
| Latency (p99) | 12.5ms | 23.4ms | 45.6ms | 
| Throughput | 850K msg/s | 420K msg/s | 180K msg/s | 
| CPU Usage | 35% | 48% | 62% | 
Test environment: AMD Ryzen 9 5900X, 32GB RAM, localhost
๐งช Testing
Running Tests
# Run all tests
# Integration tests only
# With verbose logging
RUST_LOG=debug 
Test Coverage
- โ QUIC connection/disconnection
- โ Message serialization
- โ Handler registration/invocation
- โ Error handling
- โ SystemStream lifecycle
- โ Service metadata management
- โ Automatic certificate generation
๐ง Advanced Usage
Custom Handler Implementation
use ;
;
// Registration
let registry = new;
registry.register.await;
Streaming Communication
use UnisonStream;
// Create stream
let mut stream = client.start_system_stream.await?;
// Async send/receive
spawn;
Service Metrics
let stats = service.get_performance_stats.await?;
println!;
println!;
println!;
๐ Documentation
๐ ๏ธ Development
Build Requirements
- Rust 1.70 or higher
- Tokio 1.40 or higher
- OpenSSL or BoringSSL (for QUIC)
Development Environment Setup
# Clone repository
# Install dependencies
# Start development server
# Run tests
Code Generation
# Generate code from KDL schema
# Generate TypeScript definitions
๐ค Contributing
Pull requests are welcome! Please follow these guidelines:
- Fork and create a feature branch
- Add tests (coverage 80% or higher)
- Run cargo fmtandcargo clippy
- Use Conventional Commits for commit messages
- Submit a pull request
๐ License
MIT License - See LICENSE file for details.
๐ Acknowledgments
Unison Protocol - Harmonizing communication across languages and platforms ๐ต