Skip to main content

lib_epub/
lib.rs

1//! Epub library
2//!
3//! A Rust library for reading and manipulating EPUB eBook files.
4//!
5//! This library provides complete EPUB file parsing functionality,
6//! supporting EPUB 2 and EPUB 3 formats. It can extract metadata,
7//! access content files, and handle encrypted resources.
8//! Furthermore, this library also provides a convenient way to build
9//! epub files from a set of resources.
10//!
11//! ## Features
12//!
13//! - Parse EPUB file structure and containers, extract metadata, access resource files.
14//! - Automatic handle encrypted content.
15//! - Optional EPUB build functionality via 'builder' feature.
16//! - EPUB specification-compliant verification mechanism.
17//!
18//! ## Quick Start
19//!
20//! ### Read EPUB Files
21//!
22//! ```rust, no_run
23//! # use lib_epub::epub::EpubDoc;
24//! # fn main() -> Result<(), lib_epub::error::EpubError> {
25//! // Open EPUB file
26//! let mut doc = EpubDoc::new("path/to/epub/file.epub")?;
27//!
28//! // Get metadata
29//! println!("Title: {:?}", doc.get_title());
30//! println!("Creator: {:?}", doc.get_metadata_value("creator"));
31//!
32//! // Read content
33//! if let Some((_content, _mime)) = doc.spine_current() { todo!() };
34//! if let Some((_content, _mime)) = doc.spine_next() { todo!() };
35//!
36//! # Ok(())
37//! # }
38//! ```
39//!
40//! ## Feature flags
41//!
42//! This crate uses 2 feature flags to reduce the needless code for your project.
43//! By default, this crate only provides structs and trait related to reading and parsing EPUB documents.
44//! If you want to use more features related to EPUB, please use the feature flag
45//! to turn on the section you need.
46//!
47//! - `builder`: Enable `lib_epub::builder`, provides structs and trait related to building EPUB documents.
48//! - `content-builder`: Enable `lib_epub::builder::content`, provides structs and trait
49//!   related to building EPUB content documents. Enabling this feature will turn on
50//!   the `builder` feature by default.
51//! - `no-indexmap`: Remove the dependency on the external crate `IndexMap`. This dependency
52//!   is primarily used to ensure the order of resources in the manifest, as recommended
53//!   by the EPUB specification.
54
55pub(crate) mod utils;
56
57#[cfg(feature = "builder")]
58pub mod builder;
59pub mod epub;
60pub mod error;
61pub mod types;
62
63pub use utils::DecodeBytes;