libarchive_oxide 0.1.0

Unified streaming archive library (Pure Rust). std high-level API: auto-detection, FS extraction, safe path handling.
Documentation

libarchive_oxide

crates.io docs.rs License: MIT OR Apache-2.0 unsafe: forbidden

The std high-level API of libarchive_oxide: a unified, streaming, pure-Rust archive library. It reads and writes tar / cpio / ar / zip / 7z / iso9660 (incl. zip64 and WinZip AES-256), layers gzip / zstd / xz / lz4 compression transparently over any format, and adds auto-detection, safe filesystem extraction, and a sans-IO incremental source. #![forbid(unsafe_code)], no dyn in library source.

An independent from-scratch reimplementation (the "oxidation" of libarchive); not affiliated with the upstream libarchive project nor any existing libarchive binding crate. It reuses mature pure-Rust codecs (miniz_oxide, ruzstd, lzma-rust2, lz4_flex, RustCrypto) rather than reimplementing them, on top of the no_std libarchive_oxide-core algebra.

Quick start

use libarchive_oxide::{decompress_capped, reader};
use libarchive_oxide_core::{EntryData, EntryReader};

fn list(bytes: &[u8]) -> std::io::Result<()> {
    let plain = decompress_capped(bytes, 64 * 1024 * 1024)
        .map_err(std::io::Error::other)?;    // auto-detect gzip/zstd/xz/lz4, capped
    let mut r = reader(&plain)?;             // detect tar/cpio/ar/zip/7z/iso
    while let Some(mut entry) = r.next_entry()? {
        println!("{}", String::from_utf8_lossy(&entry.meta().path));
        let mut buf = [0u8; 8192];
        while entry.data().read_chunk(&mut buf)? != 0 {}
    }
    Ok(())
}

Key entry points: decompress / decompress_capped / compress, reader / reader_with_password, extract::extract, and the create functions build_archive / build_tar / build_cpio. Runnable examples are under examples/. Full API on docs.rs.

Features

Feature Default Effect
gzip yes gzip filter (hand-written sans-IO over miniz_oxide)
zstd yes zstd filter (adapter over ruzstd)
xz yes xz / LZMA2 filter (adapter over lzma-rust2)
lz4 yes lz4 frame filter (adapter over lz4_flex)
aes no WinZip AES-256 (AE-2) zip encryption/decryption (RustCrypto)
sevenz no 7z read+write (single-folder LZMA2; implies gzip)

--no-default-features builds with the uncompressed formats only and drops every codec dependency.

Safe on untrusted input

Extraction rejects path traversal (.., absolute paths, Windows drive/UNC), and decompress_capped refuses to expand past a caller-set bound (bomb defense). The whole crate is #![forbid(unsafe_code)]. See the workspace threat model and SECURITY.md.

MSRV

1.87, set by the codec closure. --no-default-features lowers it toward the core floor (1.81).

License

Licensed under either of MIT or Apache-2.0 at your option.