Module zip

Module zip 

Source
Expand description

Async ZIP archive implementation.

This module provides AsyncZipArchive, an async implementation of the AsyncArchiveReader trait using the async-zip crate for non-blocking ZIP file access.

§Implementation Details

  • Uses async-zip with tokio compatibility layer (tokio-util::compat)
  • Wraps readers in BufReader for efficient I/O
  • Converts between tokio’s AsyncRead and futures’ AsyncRead traits

§Examples

use lib3mf_async::zip::AsyncZipArchive;
use lib3mf_async::archive::AsyncArchiveReader;
use tokio::fs::File;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Open a 3MF file (ZIP archive)
    let file = File::open("model.3mf").await?;
    let mut archive = AsyncZipArchive::new(file).await?;

    // Read an entry
    let model_rels = archive.read_entry("_rels/.rels").await?;
    println!("Relationships XML: {} bytes", model_rels.len());

    Ok(())
}

Structs§

AsyncZipArchive
Async ZIP archive reader implementing AsyncArchiveReader.