#tar-archive #tar #reader-writer #file-reader #file-writer #file-io #encoding

krata-tokio-tar

A Rust implementation of an async TAR file reader and writer. This library does not currently handle compression, but it is abstract over all I/O readers and writers. Additionally, great lengths are taken to ensure that the entire contents are never required to be entirely resident in memory all at once.

3 releases

0.4.2 Sep 10, 2024
0.4.1 Sep 10, 2024
0.4.0 Mar 30, 2024

#78 in Compression

Download history 2008/week @ 2024-07-30 2320/week @ 2024-08-06 3105/week @ 2024-08-13 2919/week @ 2024-08-20 3384/week @ 2024-08-27 3066/week @ 2024-09-03 4847/week @ 2024-09-10 4370/week @ 2024-09-17 4535/week @ 2024-09-24 4091/week @ 2024-10-01 4945/week @ 2024-10-08 5422/week @ 2024-10-15 5894/week @ 2024-10-22 4981/week @ 2024-10-29 4796/week @ 2024-11-05 3059/week @ 2024-11-12

19,703 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

150KB
3K SLoC

tokio-tar

A tar archive reading/writing library for async Rust.


Based on the great tar-rs.

Reading an archive

use tokio::io::stdin;
use tokio::prelude::*;

use tokio_tar::Archive;

fn main() {
    tokio::runtime::Runtime::new().unwrap().block_on(async {
        let mut ar = Archive::new(stdin());
        let mut entries = ar.entries().unwrap();
        while let Some(file) = entries.next().await {
            let f = file.unwrap();
            println!("{}", f.path().unwrap().display());
        }
    });
}

Writing an archive

use tokio::fs::File;
use tokio_tar::Builder;

fn main() {
    tokio::runtime::Runtime::new().unwrap().block_on(async {
        let file = File::create("foo.tar").await.unwrap();
        let mut a = Builder::new(file);

        a.append_path("README.md").await.unwrap();
        a.append_file("lib.rs", &mut File::open("src/lib.rs").await.unwrap())
            .await
            .unwrap();
    });
}

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~5–14MB
~184K SLoC