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

extern crate core;

mod archive_reader;
pub mod error;
mod lending_iter;
mod libarchive;
mod locale;

pub use crate::archive_reader::*;
pub use error::*;
#[cfg(feature = "lending_iter")]
pub use lending_iter::LendingIterator;
#[cfg(not(feature = "lending_iter"))]
use lending_iter::LendingIterator;

type Decoder = fn(&[u8]) -> Option<std::borrow::Cow<'_, str>>;