Crates.io | cra |
lib.rs | cra |
version | 0.1.3 |
source | src |
created_at | 2024-01-31 10:03:51.426386 |
updated_at | 2024-05-05 11:14:15.477839 |
description | Simple library for extracting/archiving in multiple formats fully in memory |
homepage | https://github.com/chrontax/cra |
repository | https://github.com/chrontax/cra |
max_upload_size | |
id | 1121607 |
size | 37,906 |
Simple library for extracting/archiving in multiple formats fully in memory
cargo add cra
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>