3 releases
| 0.1.0-alpha.5 | Jun 9, 2025 |
|---|---|
| 0.1.0-alpha.4 | Jun 7, 2025 |
#143 in #telemetry
74 downloads per month
24KB
297 lines
AXCP Rust SDK
Official Rust implementation of the Adaptive eXchange Context Protocol (AXCP) client SDK.
Features
- Async/await API with
tokio - Telemetry data collection and batching
- Configurable timeouts and retry policies
- Comprehensive error handling with
thiserror - Built-in metrics and tracing with
tracing - Multiple TLS backends (native-tls or rustls)
- WebSocket support for real-time communication
Installation
Add this to your Cargo.toml:
[dependencies]
axcp-rs = "0.1.0-alpha.1"
# For async runtime (if not already in your project)
tokio = { version = "1.0", features = ["full"] }
Feature Flags
default: Usesnative-tlsfor TLSrustls: Userustlsinstead ofnative-tlsdev: Include development dependencies for testing
[dependencies]
axcp-rs = { version = "0.1.0-alpha.1", default-features = false, features = ["rustls"] }
Usage
use axcp_rs::prelude::*;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
// Initialize the SDK
axcp_rs::init()?;
// Create a client with default configuration
let config = ClientConfig {
base_url: "http://localhost:8080".to_string(),
api_key: Some("your-api-key".to_string()),
..Default::default()
};
let client = Client::new(config)?;
// Send telemetry data
let telemetry = client.telemetry();
telemetry.record_metric("cpu.usage", 75.5).await?;
// Or use the builder for more complex metrics
let data = TelemetryBuilder::new("memory.used", 1024.0)
.with_tag("host", "server-1")
.with_tag("region", "us-west-2")
.build();
client.telemetry().record(data).await?;
Ok(())
}
Configuration
The ClientConfig struct supports the following options:
base_url: The base URL of the AXCP server (default:http://localhost:8080)api_key: Optional API key for authenticationtimeout_secs: Request timeout in seconds (default: 30)enable_telemetry: Whether to enable telemetry collection (default:true)
Testing
Run the tests with:
cargo test
License
Apache 2.0
Dependencies
~15–38MB
~484K SLoC