You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
Thomas Eizinger fec26926a8
Squashed 'tokio-tar/' content from commit 43dd166
3 years ago
.github/workflows Squashed 'tokio-tar/' content from commit 43dd166 3 years ago
examples Squashed 'tokio-tar/' content from commit 43dd166 3 years ago
src Squashed 'tokio-tar/' content from commit 43dd166 3 years ago
tests Squashed 'tokio-tar/' content from commit 43dd166 3 years ago
.gitignore Squashed 'tokio-tar/' content from commit 43dd166 3 years ago
Cargo.toml Squashed 'tokio-tar/' content from commit 43dd166 3 years ago
LICENSE-APACHE Squashed 'tokio-tar/' content from commit 43dd166 3 years ago
LICENSE-MIT Squashed 'tokio-tar/' content from commit 43dd166 3 years ago
README.md Squashed 'tokio-tar/' content from commit 43dd166 3 years ago

README.md

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.