krata-tokio-tar

Crates.iokrata-tokio-tar
lib.rskrata-tokio-tar
version0.4.2
sourcesrc
created_at2024-03-30 06:28:08.53933
updated_at2024-09-10 18:38:46.974497
descriptionA 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.
homepagehttps://github.com/edera-dev/tokio-tar
repositoryhttps://github.com/edera-dev/tokio-tar
max_upload_size
id1190841
size236,365
Edera Cultivator (edera-cultivator)

documentation

https://docs.rs/tokio-tar

README

tokio-tar

A tar archive reading/writing library for async Rust.

Crates.io version Download docs.rs docs

API Docs | Releases


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.

Commit count: 498

cargo fmt