sdaas_rs/lib.rs
1//! # SDaaS Rust SDK
2//!
3//! Official Rust SDK for **SDaaS** — Semantic Delta as a Service.
4//!
5//! A clean, async-first Rust SDK for computing powerful text deltas with semantic understanding.
6//!
7//! ## Features
8//!
9//! - ✨ **Fully Async** - Built on `tokio` and `reqwest`
10//! - 🔐 **Secure** - X-API-Key authentication with rustls-tls
11//! - 📊 **Delta Computation** - Compute text diffs with compression metrics
12//! - ✅ **Key Validation** - Check tier, quota, and rate limits
13//! - 🛡️ **Type-Safe** - Full serde serialization
14//!
15//! ## Quick Start
16//!
17//! ```no_run
18//! use sdaas_rs::Client;
19//!
20//! #[tokio::main]
21//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
22//! let client = Client::new(
23//! "your-api-key",
24//! "https://saas-core-production.up.railway.app"
25//! );
26//!
27//! // Compute delta
28//! let delta = client
29//! .compute_delta("Hello", "Hello World")
30//! .await?;
31//!
32//! println!("Delta: {} operations", delta.delta.len());
33//! println!("Compression: {:.1}%", delta.compression_ratio * 100.0);
34//!
35//! // Validate key
36//! let validation = client.validate_key().await?;
37//! println!("Tier: {}", validation.key.tier);
38//!
39//! Ok(())
40//! }
41//! ```
42
43pub mod client;
44pub mod types;
45
46pub use client::Client;
47pub use types::{DeltaOp, DeltaRequest, DeltaResponse, KeyValidation, ValidationResponse};
48
49pub type Result<T> = std::result::Result<T, Error>;
50
51/// Error types for the SDaaS SDK
52#[derive(Debug, thiserror::Error)]
53pub enum Error {
54 /// Network or HTTP error
55 #[error("HTTP error: {0}")]
56 Http(#[from] reqwest::Error),
57
58 /// Generic API error
59 #[error("API error: {0}")]
60 Api(String),
61
62 /// Invalid or malformed API response
63 #[error("Invalid response: {0}")]
64 InvalidResponse(String),
65
66 /// Missing or invalid API key
67 #[error("Missing or invalid API key")]
68 InvalidApiKey,
69
70 /// Rate limit exceeded (429 Too Many Requests)
71 #[error("Rate limit exceeded")]
72 RateLimitExceeded,
73
74 /// Quota exceeded (402 Payment Required)
75 #[error("Quota exceeded")]
76 QuotaExceeded,
77
78 /// Unauthorized request (401 Unauthorized)
79 #[error("Unauthorized")]
80 Unauthorized,
81}