Skip to content
smallPict

Rust SDK

메모리 안전성과 비동기 처리를 보장하는 공식 smallpict Rust crate.

공식 SmallPict Rust crate는 tokio와 reqwest 기반으로 제작되어 메모리 무할당 HMAC 서명 연산을 제공합니다.


의존성 추가 (Cargo.toml)

TOML
[dependencies]smallpict = "0.1.0"tokio = { version = "1", features = ["full"] }

빠른 시작 예제

Rust
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!("최적화 URL: {}", result.url);    println!("절감률: {}%", result.savings_percentage);
    Ok(())}