#archive #archive-format #zip-archive #extract #compression #directory #read-write

cra

Simple library for extracting/archiving in multiple formats fully in memory

4 releases

0.1.3 May 5, 2024
0.1.2 May 5, 2024
0.1.1 Feb 1, 2024
0.1.0 Jan 31, 2024

#593 in Encoding

Download history 17/week @ 2024-01-29 27/week @ 2024-02-19 30/week @ 2024-02-26 2/week @ 2024-03-04 17/week @ 2024-03-11 3/week @ 2024-03-25 7/week @ 2024-04-01 1/week @ 2024-04-22 161/week @ 2024-04-29 84/week @ 2024-05-06

246 downloads per month
Used in 2 crates (via comiconv)

MIT/Apache

12KB
241 lines

Cra

Simple library for extracting/archiving in multiple formats fully in memory

Features

  • effortlessly read archives and iterate over their entries
  • support for 7z, zip and tar
  • fully in memory
  • create archives in any supported format

Usage

cargo add cra

Examples

Read and iterate over archive:

use cra::{ArcReader, ArcEntry};

let mut archive = ArcReader::new(&archive_bytes).unwrap();

for entry in archive {
    match entry {
        ArcEntry::File(name, data) => { /* do something */ }
        ArcEntry::Directory(name) => { /* do something else */ }
    }
}

Create a zip archive with a directory and a file:

use cra::{ArcWriter, ArcEntry, ArcFormat};

let mut writer = ArcWriter::new(Format::Zip);

writer.push(ArcEntry::Directory(String::from("some_dir")));
writer.push(ArcEntry::File(String::from("some_file"), data));

let finished_archive = writer.archive().unwrap(); // Vec<u8>

lib.rs:

Simple abstraction over archive formats.

You can read and write archives in zip, 7z, and tar formats.

Dependencies

~9–19MB
~258K SLoC