#tar #tarfile #encoding

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.

2 unstable releases

0.2.0 Mar 15, 2020
0.1.0 Jan 9, 2020

#10 in #tar

Download history 22/week @ 2020-12-24 52/week @ 2020-12-31 232/week @ 2021-01-07 281/week @ 2021-01-14 323/week @ 2021-01-21 238/week @ 2021-01-28 144/week @ 2021-02-04 143/week @ 2021-02-11 79/week @ 2021-02-18 172/week @ 2021-02-25 192/week @ 2021-03-04 105/week @ 2021-03-11 211/week @ 2021-03-18 212/week @ 2021-03-25 52/week @ 2021-04-01 123/week @ 2021-04-08

721 downloads per month

MIT/Apache

145KB
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

~2MB
~33K SLoC