archive_reader/
lib.rs

1//! `ArchiveReader` is a library that wraps partial read functions from libarchive.
2//! It provides rustic interface over listing file names and reading given files within archives.
3//!
4//! # Example
5//! ```rust,no_run
6//! use archive_reader::Archive;
7//! use archive_reader::error::Result;
8//!
9//! fn main() -> Result<()> {
10//!     let mut archive = Archive::open("some_archive.zip");
11//!     let file_names = archive
12//!                         .block_size(1024 * 1024)
13//!                         .list_file_names()?
14//!                         .collect::<Result<Vec<_>>>()?;
15//!     let mut content = vec![];
16//!     let _ = archive.read_file(&file_names[0], &mut content)?;
17//!     println!("content={content:?}");
18//!     Ok(())
19//! }
20//! ```
21//! # Features
22//! * `lending_iter` - Enables `LendingIterator` implementation, which avoids heap allocations for `read_file_by_block` function.
23//!
24
25extern crate core;
26
27mod archive_reader;
28pub mod error;
29mod lending_iter;
30mod libarchive;
31mod locale;
32
33pub use crate::archive_reader::*;
34pub use error::*;
35#[cfg(feature = "lending_iter")]
36pub use lending_iter::LendingIterator;
37#[cfg(not(feature = "lending_iter"))]
38use lending_iter::LendingIterator;
39
40type Decoder = fn(&[u8]) -> Option<std::borrow::Cow<'_, str>>;