Crate pna

Crate pna 

Source
Expand description

A library for more useful reading and writing PNA archives

Provides filesystem-related utilities in addition to the utilities necessary to manage PNA archives abstracted over a reader or writer hosted by libpna.

§pna

test Crates.io docs.rs

A pna archive reading/writing library for Rust.

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

§Reading an archive

use pna::{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 pna::{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(())
}

§CLI

A command-line interface (CLI) is available. You can install it via Cargo or build from source.

§Via Cargo

cargo install portable-network-archive

§From Source (via Cargo)

cargo install --git https://github.com/ChanTsune/Portable-Network-Archive.git portable-network-archive

§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.

Modules§

fs
PNA filesystem utilities
prelude
PNA Prelude.

Structs§

Archive
An object providing access to a PNA file. An instance of an Archive can be read and/or written.
ChunkType
A 4-byte chunk type code.
CompressionLevel
Compression level of each algorithm.
Duration
A span of time with nanosecond precision.
EntryBuilder
A builder for creating a NormalEntry.
EntryDataReader
Reader for Entry data.
EntryHeader
Represents the entry information header that expressed in the FHED chunk.
EntryName
A UTF-8 encoded entry name.
EntryNameError
Error of invalid EntryName.
EntryPart
A structure representing the split Entry for archive splitting.
EntryReference
A UTF-8 encoded entry reference.
EntryReferenceError
Error of invalid EntryReference.
ExtendedAttribute
Represents a single extended attribute of a file entry.
HashAlgorithm
Password hash algorithm.
Metadata
Metadata information about an entry.
NormalEntry
A normal entry in a PNA archive.
Permission
Permission struct represents an owner, group, and permissions for an entry.
RawChunk
A raw chunk in a PNA archive.
ReadOptions
Options for reading an entry.
ReadOptionsBuilder
Builder for ReadOptions.
SolidArchive
An object that provides write access to solid mode PNA files.
SolidEntry
A solid mode entry in a PNA archive.
SolidEntryBuilder
A builder for creating a SolidEntry.
SolidHeader
Represents the entry information header that expressed in the SHED chunk.
UnknownValueError
Unknown value error.
WriteOptions
Options for writing entries to a PNA archive.
WriteOptionsBuilder
Builder for WriteOptions.

Enums§

ChunkTypeError
ChunkType validation error.
CipherAlgorithm
Cipher algorithm.
CipherMode
Cipher mode of encryption algorithm.
Compression
Compression method.
DataKind
Type of filesystem object represented by an entry.
Encryption
Encryption algorithm.
ReadEntry
A NormalEntry or SolidEntry read from an archive.

Constants§

MIN_CHUNK_BYTES_SIZE
The minimum size of a PNA chunk in bytes.
PNA_HEADER
The magic number of Portable-Network-Archive

Traits§

Chunk
A trait representing a chunk in a PNA archive.
Entry
A trait representing an entry in a PNA archive.

Functions§

read_as_chunks
Reads an archive as chunks from the given reader.
read_chunks_from_slice
Reads an archive as chunks from the given bytes.