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

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.

4 releases (2 breaking)

0.3.1 Jul 14, 2023
0.3.0 May 18, 2021
0.2.0 Mar 15, 2020
0.1.0 Jan 9, 2020

#118 in Parser implementations

Download history 25992/week @ 2024-07-22 25385/week @ 2024-07-29 25717/week @ 2024-08-05 22412/week @ 2024-08-12 25050/week @ 2024-08-19 26662/week @ 2024-08-26 26311/week @ 2024-09-02 22366/week @ 2024-09-09 22892/week @ 2024-09-16 29562/week @ 2024-09-23 34931/week @ 2024-09-30 42518/week @ 2024-10-07 45240/week @ 2024-10-14 53729/week @ 2024-10-21 52904/week @ 2024-10-28 49574/week @ 2024-11-04

203,350 downloads per month
Used in 91 crates (29 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

~4–13MB
~164K SLoC