#zip-archive #zip #archive #future #async

async_zip_futures

An asynchronous ZIP archive reading/writing crate using futures-rs

1 unstable release

0.0.12 Mar 10, 2023

#595 in Asynchronous

MIT license

82KB
1.5K SLoC

async_zip_futures

Crates.io Crates.io docs.rs GitHub Workflow Status (branch) GitHub

An asynchronous ZIP archive reading/writing crate powered by futures-rs.

Forked from rs-async-zip. tokio was replaced with futures-rs.

Features

  • Support for Stored compression method.
  • Support for writing streams using data descriptors.
  • Initial support for ZIP64 writing.
  • Aims for reasonable specification compliance.

Installation & Basic Usage

[dependencies]
async_zip_futures = { version = "0.0.12", features = ["full"] }

A (soon to be) extensive list of examples can be found under the /examples directory.

Feature Flags

  • full - Enables all below features.
  • chrono - Enables support for parsing dates via chrono.

Writing

use async_zip_futures::{Compression, ZipEntryBuilder, write::ZipFileWriter, error::ZipError};
use futures::AsyncWriteExt;
use tokio::fs::File;
use tokio_util::compat::TokioAsyncReadCompatExt;
...

let mut file = File::create("foo.zip").await.unwrap().compat();
let mut writer = ZipFileWriter::new(&mut file);

let data = b"This is an example file.";
let builder = ZipEntryBuilder::new(String::from("bar.txt"), Compression::Stored);

let mut entry_writer = writer.write_entry_stream(builder).await.unwrap();
entry_writer.write_all(data).await.unwrap();
entry_writer.close().await.unwrap();
writer.close().await.unwrap();

Dependencies

~1–6.5MB
~43K SLoC