#pna #archive #file-format #cryptography

libpna

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

45 releases (24 breaking)

new 0.24.2 Apr 12, 2025
0.24.1 Mar 26, 2025
0.23.0 Feb 9, 2025
0.20.3 Dec 30, 2024
0.0.0-alpha.1 Mar 7, 2023

#573 in Data structures

Download history 442/week @ 2024-12-27 579/week @ 2025-01-03 299/week @ 2025-01-10 414/week @ 2025-01-17 407/week @ 2025-01-24 197/week @ 2025-01-31 279/week @ 2025-02-07 223/week @ 2025-02-14 434/week @ 2025-02-21 144/week @ 2025-02-28 137/week @ 2025-03-07 195/week @ 2025-03-14 394/week @ 2025-03-21 547/week @ 2025-03-28 320/week @ 2025-04-04 259/week @ 2025-04-11

1,643 downloads per month
Used in 3 crates (via pna)

Apache-2.0 OR MIT

270KB
6.5K SLoC

libpna

test Crates.io

A pna archive reading/writing library for Rust.

# Cargo.toml
[dependencies]
libpna = "0.24"

Reading an archive

use libpna::{Archive, ReadOptions};
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(ReadOptions::builder().build())?;
        copy(&mut reader, &mut file)?;
    }
    Ok(())
}

Writing an archive

use libpna::{Archive, EntryBuilder, WriteOptions};
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(),
        WriteOptions::builder().build(),
    )?;
    entry_builder.write(b"content")?;
    let entry = entry_builder.build()?;
    archive.add_entry(entry)?;
    archive.finalize()?;
    Ok(())
}

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

~14MB
~213K SLoC