sdaas-rs 0.1.0

Official Rust SDK for SDaaS — Semantic Delta as a Service
Documentation
//! # SDaaS Rust SDK
//!
//! Official Rust SDK for **SDaaS** — Semantic Delta as a Service.
//!
//! A clean, async-first Rust SDK for computing powerful text deltas with semantic understanding.
//!
//! ## Features
//!
//! - ✨ **Fully Async** - Built on `tokio` and `reqwest`
//! - 🔐 **Secure** - X-API-Key authentication with rustls-tls
//! - 📊 **Delta Computation** - Compute text diffs with compression metrics
//! - ✅ **Key Validation** - Check tier, quota, and rate limits
//! - 🛡️ **Type-Safe** - Full serde serialization
//!
//! ## Quick Start
//!
//! ```no_run
//! use sdaas_rs::Client;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!     let client = Client::new(
//!         "your-api-key",
//!         "https://saas-core-production.up.railway.app"
//!     );
//!
//!     // Compute delta
//!     let delta = client
//!         .compute_delta("Hello", "Hello World")
//!         .await?;
//!
//!     println!("Delta: {} operations", delta.delta.len());
//!     println!("Compression: {:.1}%", delta.compression_ratio * 100.0);
//!
//!     // Validate key
//!     let validation = client.validate_key().await?;
//!     println!("Tier: {}", validation.key.tier);
//!
//!     Ok(())
//! }
//! ```

pub mod client;
pub mod types;

pub use client::Client;
pub use types::{DeltaOp, DeltaRequest, DeltaResponse, KeyValidation, ValidationResponse};

pub type Result<T> = std::result::Result<T, Error>;

/// Error types for the SDaaS SDK
#[derive(Debug, thiserror::Error)]
pub enum Error {
    /// Network or HTTP error
    #[error("HTTP error: {0}")]
    Http(#[from] reqwest::Error),

    /// Generic API error
    #[error("API error: {0}")]
    Api(String),

    /// Invalid or malformed API response
    #[error("Invalid response: {0}")]
    InvalidResponse(String),

    /// Missing or invalid API key
    #[error("Missing or invalid API key")]
    InvalidApiKey,

    /// Rate limit exceeded (429 Too Many Requests)
    #[error("Rate limit exceeded")]
    RateLimitExceeded,

    /// Quota exceeded (402 Payment Required)
    #[error("Quota exceeded")]
    QuotaExceeded,

    /// Unauthorized request (401 Unauthorized)
    #[error("Unauthorized")]
    Unauthorized,
}