Rust SDK
Official smallpict crate for memory-safe, ultra-high-performance asynchronous Rust applications.
Rust SDK (smallpict)
The official SmallPict Rust crate is built on top of tokio and reqwest with zero-allocation HMAC signing.
📦 Installation (Cargo.toml)
[dependencies]
smallpict = "0.1.0"
tokio = { version = "1", features = ["full"] }
🚀 Quickstart Example
use smallpict::{SmallPictClient, OptimizeOptions};
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = SmallPictClient::new(
std::env::var("SMALLPICT_API_KEY")?,
std::env::var("SMALLPICT_SECRET_KEY")?,
)?;
let image_bytes = fs::read("hero.jpg")?;
let result = client.optimize(&image_bytes, OptimizeOptions::new().format("avif").quality(80)).await?;
println!("Optimized URL: {}", result.url);
println!("Savings: {}%", result.savings_percentage);
Ok(())
}
