axcp-rs 0.1.0-alpha.5

Rust client SDK for AXCP protocol
Documentation

AXCP Rust SDK

Crates.io Documentation License Rust

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: Uses native-tls for TLS
  • rustls: Use rustls instead of native-tls
  • dev: 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 authentication
  • timeout_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