Skip to content
smallPict
Mulai Gratis

SDK Rust

Crate resmi smallpict untuk aplikasi Rust asinkron yang aman memori.

Crate Rust resmi SmallPict dibangun di atas framework tokio dan reqwest dengan penandatanganan HMAC zero-allocation.


Instalasi (Cargo.toml)

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

Contoh Penggunaan

Rust
use smallpict::{Client, OptimizeOptions};
#[tokio::main]async fn main() -> Result<(), Box<dyn std::error::Error>> {    let client = Client::new("sp_sdk_your_key", "sec_your_secret");
    let image_data = std::fs::read("hero.jpg")?;    let res = client.optimize(image_data, OptimizeOptions::new().format("avif").quality(80)).await?;
    println!("URL Teroptimasi: {}", res.url);    Ok(())}