#archive #archive-data #pna

libpna

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

55 releases (28 breaking)

new 0.28.2 Oct 31, 2025
0.28.0 Sep 28, 2025
0.27.0 Jul 23, 2025
0.24.1 Mar 26, 2025
0.0.0-alpha.1 Mar 7, 2023

#713 in Data structures

Download history 413/week @ 2025-07-13 400/week @ 2025-07-20 140/week @ 2025-07-27 128/week @ 2025-08-03 331/week @ 2025-08-10 158/week @ 2025-08-17 638/week @ 2025-08-24 246/week @ 2025-08-31 404/week @ 2025-09-07 243/week @ 2025-09-14 210/week @ 2025-09-21 265/week @ 2025-09-28 164/week @ 2025-10-05 448/week @ 2025-10-12 294/week @ 2025-10-19 325/week @ 2025-10-26

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

Apache-2.0 OR MIT

310KB
7K SLoC

libpna

test Crates.io

A pna archive reading/writing library for Rust.

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

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
~226K SLoC