#zip-archive #multi-threading #data #hold #deflate

mtzip

A library for making zip archives with multithreaded compression

19 releases (6 stable)

2.0.1 Apr 12, 2024
1.3.0 Mar 24, 2024
1.2.0 Oct 29, 2023
1.1.0 Jun 7, 2023
0.3.0 Nov 30, 2022

#96 in Compression

Download history 116/week @ 2024-02-11 1/week @ 2024-02-18 11/week @ 2024-02-25 138/week @ 2024-03-24 32/week @ 2024-03-31 209/week @ 2024-04-07 23/week @ 2024-04-14

402 downloads per month
Used in rfmp

MIT license

40KB
790 lines

crates.io crates.io

mtzip

MTZIP (Stands for Multi-Threaded ZIP) is a library for making zip archives while utilising all available performance available with multithreading. The amount of threads can be limited by the user or detected automatically.

Example usage:

use mtzip::ZipArchive;

// Creating the zipper that holds data and handles compression
let zipper = ZipArchive::default();

// Adding a file from filesystem
zipper.add_file_from_fs("input/test_text_file.txt", "test_text_file.txt");

// Adding a file from a byte array
zipper.add_file_from_memory(b"Hello, world!", "hello_world.txt");

// Adding a directory and a file to it
zipper.add_directory("test_dir");
// And adding a file to it
zipper.add_file_from_fs("input/file_that_goes_to_a_dir.txt", "test_dir/file_that_goes_to_a_dir.txt");

// Writing to a file
// First, open the file
let mut file = File::create("output.zip").unwrap();
// Then, write to it
zipper.write(&mut file); // Amount of threads is chosen automatically

The amount of threads is also determined by the amount of files that are going to be compressed. Because Deflate compression cannot be multithreaded, the multithreading is achieved by having the files compressed individually. This means that if you have 12 threads available but only 6 files being added to the archive, you will only use 6 threads.

Dependencies

~0.3–0.9MB
~13K SLoC