Crate libarchive2

Crate libarchive2 

Source
Expand description

Safe Rust bindings for libarchive

This crate provides idiomatic Rust bindings to libarchive, supporting reading and writing various archive formats (tar, zip, 7z, etc.) with multiple compression formats.

§Examples

§Reading an archive

use libarchive2::ReadArchive;

// Reading from a file (lifetime is 'static)
let mut archive = ReadArchive::open("archive.tar.gz")?;

while let Some(entry) = archive.next_entry()? {
    println!("File: {}", entry.pathname().unwrap_or_default());
    // Read entry data...
}

§Writing an archive

use libarchive2::{WriteArchive, ArchiveFormat, CompressionFormat};

let mut archive = WriteArchive::new()
    .format(ArchiveFormat::Tar)
    .compression(CompressionFormat::Gzip)
    .open_file("output.tar.gz")?;

archive.add_file("file.txt", b"Hello, world!")?;

Structs§

AclEntry
ACL entry
AclPermissions
ACL permission flags
ArchiveMatch
Archive matcher for filtering entries based on patterns
CallbackReader
Builder for reading archives with custom Read implementations
CallbackWriter
Builder for writing archives with custom Write implementations
CompressionLevel
Compression level (0-9)
Entry
Immutable reference to an archive entry
EntryMut
Mutable reference to an archive entry for building/writing
ExtractFlags
Flags for controlling extraction behavior
ProgressTracker
Progress tracker for monitoring archive operations
ReadArchive
Archive reader with RAII resource management
ReadDisk
Archive reader for reading files from disk
ReadDiskFlags
Behavior flags for reading from disk
WriteArchive
Archive writer with builder pattern and RAII resource management
WriteDisk
Archive writer for extracting entries to disk
Xattr
Extended attribute (xattr)

Enums§

AclTag
ACL tag type
AclType
ACL entry type
ArchiveFormat
Archive format types
CompressionFormat
Compression format types
Error
Error type for libarchive operations
FileType
File type of an archive entry
FilterOption
Filter-specific options for compression
FormatOption
Format-specific options for archive writing
ReadFormat
Format specifier for reading archives
SymlinkMode
Symlink handling mode
ZipCompressionMethod
ZIP compression method options

Traits§

EntryAclExt
Extension trait for Entry to add ACL/xattr reading
EntryMutAclExt
Extension trait for EntryMut to add ACL/xattr manipulation
ProgressCallback
Trait for progress tracking callbacks

Functions§

version
Returns the version string of the underlying libarchive library
version_details
Returns detailed version information including linked libraries
version_number
Returns the version number of the underlying libarchive library

Type Aliases§

Result
Result type for libarchive operations