Expand description
Async archive reader abstraction layer.
This module provides the AsyncArchiveReader trait, which defines the interface for
asynchronously reading entries from archive containers (ZIP files). It mirrors the synchronous
lib3mf_core::archive::ArchiveReader trait but with async methods.
§Design
The trait abstracts over different async archive implementations, allowing the 3MF loader
to work with any async archive backend. Currently, AsyncZipArchive is the primary
implementation using the async-zip crate.
§Examples
use lib3mf_async::archive::AsyncArchiveReader;
use lib3mf_async::zip::AsyncZipArchive;
use tokio::fs::File;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let file = File::open("model.3mf").await?;
let mut archive = AsyncZipArchive::new(file).await?;
// Check if an entry exists
if archive.entry_exists("_rels/.rels").await {
// Read the entry
let data = archive.read_entry("_rels/.rels").await?;
println!("Read {} bytes", data.len());
}
// List all entries
let entries = archive.list_entries().await?;
println!("Archive contains {} entries", entries.len());
Ok(())
}Traits§
- Async
Archive Reader - Trait for reading entries from an archive asynchronously.