apk_info_zip/lib.rs
1//! Implementation of a custom error-agnostic zip parser
2//!
3//! The main purpose of this crate is to correctly unpack archives damaged using the `BadPack` technique.
4//!
5//! Archives are read lazily from any seekable source ([`ZipEntry::open`],
6//! [`ZipEntry::from_reader`], [`ZipEntry::new`]): only the central directory
7//! is kept in memory, so a multi-gigabyte apk costs as much memory as the
8//! entries actually requested.
9//!
10//! ## Example
11//!
12//! ```no_run
13//! # use apk_info_zip::ZipEntry;
14//! let zip = ZipEntry::open("app.apk").expect("can't parse zip file");
15//! let (data, compression_method) = zip.read("AndroidManifest.xml").expect("can't read manifest");
16//! ```
17
18#![doc(
19 html_logo_url = "https://raw.githubusercontent.com/delvinru/apk-info/main/docs/assets/logo/logo-256.png"
20)]
21#![doc(
22 html_favicon_url = "https://raw.githubusercontent.com/delvinru/apk-info/main/docs/assets/logo/favicon-32.png"
23)]
24
25pub mod anomaly;
26pub mod compression;
27pub mod entry;
28pub mod errors;
29pub mod signature;
30
31mod ber;
32mod name;
33mod source;
34mod structs;
35mod writer;
36
37pub use anomaly::ZipAnomaly;
38pub use compression::*;
39pub use entry::*;
40pub use errors::*;
41pub use signature::*;
42pub use source::ReadSeek;
43
44/// Internals reachable from the fuzz targets only.
45#[cfg(feature = "fuzzing")]
46#[doc(hidden)]
47pub mod fuzzing {
48 /// See `ber::to_der`.
49 pub fn ber_to_der(input: &[u8]) -> Option<Vec<u8>> {
50 crate::ber::to_der(input)
51 }
52}