peasy-compress 0.2.2

Rust client for PeasyCompress — file compression tools, glossary, and guides API
Documentation

peasy-compress

crates.io docs.rs License: MIT crates.io GitHub stars

Async Rust client for the Peasy Compress API -- compress, archive, and extract files with ZIP, TAR, gzip, Brotli, and Zstandard. Built with reqwest, serde, and tokio.

Built from Peasy Tools, a comprehensive file compression toolkit offering free online tools for creating and extracting archives across multiple formats. The glossary covers compression algorithms from classic DEFLATE to modern Brotli and Zstandard, while guides compare archive formats and explain lossless vs lossy compression strategies.

Explore compression formats at peasytools.com -- ZIP, TAR, Gzip, and more.

Table of Contents

Install

[dependencies]
peasy-compress = "0.2.0"
tokio = { version = "1", features = ["full"] }

Or via cargo:

cargo add peasy-compress

Quick Start

use peasy_compress::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    // List available compression tools
    let tools = client.list_tools(&Default::default()).await?;
    for tool in &tools.results {
        println!("{}: {}", tool.name, tool.description);
    }

    Ok(())
}

What You Can Do

Compression and Archive Tools

File compression reduces storage costs and speeds up network transfers. Archive formats like ZIP and TAR bundle multiple files into a single container, while compression algorithms like DEFLATE, Brotli, and Zstandard reduce the size of the archived data. Understanding which format to use -- ZIP for cross-platform compatibility, TAR+gzip for Unix workflows, or Brotli for web content delivery -- is critical for choosing the right tool for each task.

Format Type Best For
ZIP Archive + Compression Cross-platform file sharing, per-file compression
TAR Archive only Unix/Linux bundles, combined with gzip or Brotli
gzip Compression only Single file compression, HTTP content encoding
Brotli Compression only Web assets, higher compression ratios than gzip
Zstandard Compression only Fast real-time compression, database backups
use peasy_compress::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    // Fetch the ZIP compression tool details
    let tool = client.get_tool("zip-compress").await?;
    println!("Tool: {}", tool.name);           // ZIP compression tool
    println!("Category: {}", tool.category);   // Archive and compression category

    // List supported compression and archive formats
    let formats = client.list_formats(&Default::default()).await?;
    for fmt in &formats.results {
        println!(".{} -- {} ({})", fmt.extension, fmt.name, fmt.mime_type);
    }

    Ok(())
}

Learn more: ZIP Format Reference · TAR Format Reference · Archive Formats Compared

Browse Compression Reference Content

The compression glossary explains key concepts from basic archiving terminology to advanced algorithm details. Understanding the difference between lossless and lossy compression, how DEFLATE works under the hood, and when to choose Brotli over gzip helps developers make informed decisions about their compression pipelines.

Glossary Term Description
Archive A single file containing multiple files and directory structures
TAR Tape Archive format that bundles files without compression
Brotli Google-developed compression algorithm optimized for web content
Lossless Compression Compression that preserves all original data upon decompression
Zstandard Facebook-developed algorithm balancing speed and compression ratio
// Browse compression glossary terms programmatically
let glossary = client.list_glossary(&peasy_compress::ListOptions {
    search: Some("gzip".into()),
    ..Default::default()
}).await?;
for term in &glossary.results {
    println!("{}: {}", term.term, term.definition); // Compression algorithm definition
}

// Read in-depth guides comparing archive formats
let guides = client.list_guides(&peasy_compress::ListGuidesOptions {
    category: Some("compression".into()),
    ..Default::default()
}).await?;
for guide in &guides.results {
    println!("{} ({})", guide.title, guide.audience_level); // Guide title and difficulty
}

Learn more: Archive Glossary · Brotli Glossary · Lossless vs Lossy Compression Guide

Search and Discovery

The unified search endpoint queries across all compression tools, glossary terms, guides, and supported file formats simultaneously. This is useful for building CLI tools, documentation search, or CI/CD integrations that need to find the right compression approach.

// Search across all compression tools, glossary, and guides
let results = client.search("zip", Some(20)).await?;
println!("Found {} tools, {} glossary terms",
    results.results.tools.len(),
    results.results.glossary.len()); // Cross-content compression search results

Learn more: TAR Glossary · Lossless Compression Glossary · Zstandard Glossary

API Client

The client wraps the Peasy Tools REST API with strongly-typed Rust structs using serde deserialization.

use peasy_compress::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    // Or with a custom base URL:
    // let client = Client::with_base_url("https://custom.example.com");

    // List tools with filters
    let opts = peasy_compress::ListOptions {
        page: Some(1),
        limit: Some(10),
        search: Some("zip".into()),
        ..Default::default()
    };
    let tools = client.list_tools(&opts).await?;

    // Get a specific tool
    let tool = client.get_tool("zip-compress").await?;
    println!("{}: {}", tool.name, tool.description);

    // Search across all content
    let results = client.search("zip", Some(20)).await?;
    println!("Found {} tools", results.results.tools.len());

    // Browse the glossary
    let glossary = client.list_glossary(&peasy_compress::ListOptions {
        search: Some("gzip".into()),
        ..Default::default()
    }).await?;
    for term in &glossary.results {
        println!("{}: {}", term.term, term.definition);
    }

    // Discover guides
    let guides = client.list_guides(&peasy_compress::ListGuidesOptions {
        category: Some("compression".into()),
        ..Default::default()
    }).await?;
    for guide in &guides.results {
        println!("{} ({})", guide.title, guide.audience_level);
    }

    // List format conversions
    let conversions = client.list_conversions(&peasy_compress::ListConversionsOptions {
        source: Some("zip".into()),
        ..Default::default()
    }).await?;

    Ok(())
}

Available Methods

Method Description
list_tools(&opts) List tools (paginated, filterable)
get_tool(slug) Get tool by slug
list_categories(&opts) List tool categories
list_formats(&opts) List file formats
get_format(slug) Get format by slug
list_conversions(&opts) List format conversions
list_glossary(&opts) List glossary terms
get_glossary_term(slug) Get glossary term
list_guides(&opts) List guides
get_guide(slug) Get guide by slug
list_use_cases(&opts) List use cases
search(query, limit) Search across all content
list_sites() List Peasy sites
openapi_spec() Get OpenAPI specification

Full API documentation at peasytools.com/developers/. OpenAPI 3.1.0 spec: peasytools.com/api/openapi.json.

Learn More About Compression

Also Available

Language Package Install
Python peasy-compress pip install "peasy-compress[all]"
TypeScript peasy-compress npm install peasy-compress
Go peasy-compress-go go get github.com/peasytools/peasy-compress-go
Ruby peasy-compress gem install peasy-compress

Peasy Developer Tools

Part of the Peasy Tools open-source developer ecosystem.

Package PyPI npm crates.io Description
peasy-pdf PyPI npm crate PDF merge, split, rotate, compress -- peasypdf.com
peasy-image PyPI npm crate Image resize, crop, convert, compress -- peasyimage.com
peasy-audio PyPI npm crate Audio trim, merge, convert, normalize -- peasyaudio.com
peasy-video PyPI npm crate Video trim, resize, thumbnails, GIF -- peasyvideo.com
peasy-css PyPI npm crate CSS minify, format, analyze -- peasycss.com
peasy-compress PyPI npm crate ZIP, TAR, gzip compression -- peasytools.com
peasy-document PyPI npm crate Markdown, HTML, CSV, JSON conversion -- peasyformats.com
peasytext PyPI npm crate Text case conversion, slugify, word count -- peasytext.com

License

MIT