Ziti Rust SDK
A high-performance, async-first Rust implementation that provides secure, zero-trust networking capabilities through the OpenZiti platform. This is an unofficial SDK.
Features
- Zero Trust Architecture: End-to-end encrypted connections with identity-based access control
- Async/Await Support: Built on Tokio for high-performance asynchronous networking
- Service Discovery: Automatic discovery and connection to Ziti services
- Edge Router Integration: Smart routing through Ziti edge routers
- Session Management: Automatic API and network session management
- Identity Management: Support for certificate-based identity authentication
- Error Recovery: Comprehensive error handling with automatic retry capabilities
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
= { = "1.0", = ["full"] }
Getting Started
Prerequisites
Before using the Ziti Rust SDK, you'll need:
- A Ziti Network: Access to a running Ziti controller and edge routers
- Identity File: A valid Ziti identity file (
.json) with appropriate service policies - Service Configuration: Services configured in your Ziti network with proper access policies
Basic Example
use ;
async
Usage Examples
Dialing a Service (Client)
use ;
use ;
async
Listening on a Service (Server)
use ;
use ;
async
Using Connection Options
use ;
use Duration;
async
Configuration
Identity Files
Ziti identity files are JSON documents containing certificates and configuration:
Loading Configuration
use ;
// Method 1: Load from file (recommended)
let context = from_file.await?;
// Method 2: Build programmatically (future feature)
let context = new
.with_config
.build
.await?;
Environment Variables
The SDK respects these environment variables:
ZITI_IDENTITY_FILE: Default path to identity fileZITI_LOG_LEVEL: Logging level (error, warn, info, debug, trace)
Error Handling
The SDK provides comprehensive error types for different scenarios:
use ;
async
Error Recovery
The SDK provides helper methods for error categorization:
use ZitiError;
Advanced Usage
Context Management
use ;
// Create context with existing managers
let identity_manager = load_from_file.await?;
let session_manager = new;
let context = from_managers;
// Access underlying managers
let identity = context.identity_manager;
let sessions = context.session_manager;
Connection Lifecycle
use ;
use ;
async
API Reference
Core Types
Context- Main SDK entry pointZitiStream- Bidirectional communication streamZitiListener- Server listener for incoming connections
Configuration Types
DialOptions- Options for outbound connectionsListenOptions- Options for service hostingZitiConfig- SDK configuration
Error Types
ZitiError- Comprehensive error enumerationZitiResult<T>- Result type alias
Examples
See the examples/ directory for complete working examples:
simple_client.rs- Basic client connectionsimple_server.rs- Basic server implementationecho_server.rs- Echo server with error handlinghttp_proxy.rs- HTTP proxy over Ziti
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Documentation: https://docs.rs/ziti-sdk
- Issues: GitHub Issues
Related Projects
- OpenZiti - The main OpenZiti project
- Ziti SDK for C - C SDK implementation
- Ziti SDK for Go - Go SDK implementation