#archive #data #pna #codec #fs-file #crypto

libpna

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

34 releases (20 breaking)

new 0.20.1 Dec 12, 2024
0.20.0 Nov 17, 2024
0.19.0 Oct 15, 2024
0.15.0 Jul 27, 2024
0.0.0-alpha.1 Mar 7, 2023

#571 in Data structures

Download history 88/week @ 2024-08-25 300/week @ 2024-09-01 32/week @ 2024-09-08 139/week @ 2024-09-15 178/week @ 2024-09-22 110/week @ 2024-09-29 46/week @ 2024-10-06 292/week @ 2024-10-13 43/week @ 2024-10-20 142/week @ 2024-10-27 85/week @ 2024-11-03 113/week @ 2024-11-10 246/week @ 2024-11-17 139/week @ 2024-11-24 170/week @ 2024-12-01 460/week @ 2024-12-08

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

Apache-2.0 OR MIT

255KB
6K SLoC

libpna

test Crates.io

A pna archive reading/writing library for Rust.

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

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

~12MB
~213K SLoC