#archive #data #crypto #codec

pna

PNA(Portable-Network-Archive) decoding and encoding library

14 releases (breaking)

new 0.10.0 Apr 27, 2024
0.8.1 Apr 6, 2024
0.8.0 Mar 6, 2024
0.5.0 Dec 9, 2023
0.0.0-alpha.1 Mar 7, 2023

#990 in Data structures

Download history 11/week @ 2024-01-20 17/week @ 2024-01-27 12/week @ 2024-02-03 171/week @ 2024-02-17 51/week @ 2024-02-24 151/week @ 2024-03-02 65/week @ 2024-03-09 17/week @ 2024-03-16 23/week @ 2024-03-23 12/week @ 2024-03-30 184/week @ 2024-04-06 206/week @ 2024-04-13 7/week @ 2024-04-20

409 downloads per month
Used in portable-network-archive

Apache-2.0 OR MIT

200KB
4.5K SLoC

pna

test Crates.io

A pna archive reading/writing library for Rust.

# Cargo.toml
[dependencies]
pna = "0.10"

Reading an archive

use pna::{Archive, ReadOption};
use std::fs::File;
use std::io::{self, copy, prelude::*};

fn main() -> io::Result<()> {
    let file = File::open("foo.pna")?;
    let mut archive = Archive::read_header(file)?;
    for entry in archive.entries_skip_solid() {
        let entry = entry?;
        let mut file = File::create(entry.header().path().as_path())?;
        let mut reader = entry.reader(ReadOption::builder().build())?;
        copy(&mut reader, &mut file)?;
    }
    Ok(())
}

Writing an archive

use pna::{Archive, EntryBuilder, WriteOption};
use std::fs::File;
use std::io::{self, prelude::*};

fn main() -> io::Result<()> {
    let file = File::create("foo.pna")?;
    let mut archive = Archive::write_header(file)?;
    let mut entry_builder = EntryBuilder::new_file(
        "bar.txt".into(),
        WriteOption::builder().build(),
    )?;
    entry_builder.write(b"content")?;
    let entry = entry_builder.build()?;
    archive.add_entry(entry)?;
    archive.finalize()?;
    Ok(())
}

CLI

Command line user interface are available and you can install via cargo or build from source.

Via Cargo

cargo install portable-network-archive

From Source (via Cargo)

git clone https://github.com/ChanTsune/Portable-Network-Archive.git
cd Portable-Network-Archive
cargo install --path cli

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

~8.5MB
~156K SLoC