-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
SV-Stark edited this page Aug 5, 2026
·
1 revision
ebook-rs provides a clean, unified API for loading, inspecting, searching, and displaying eBooks in Rust applications.
Add ebook-rs to your Cargo.toml:
[dependencies]
ebook-rs = "0.2.0"use ebook_rs::Book;
fn main() -> Result<(), String> {
// Book::from_file auto-detects format from magic bytes
let mut book = Book::from_file("book.epub")?;
println!("Title: {}", book.metadata().title);
println!("Author: {:?}", book.metadata().creators);
println!("Total Chapters: {}", book.spine().len());
Ok(())
}let matches = book.search("Wonderland");
for m in matches {
println!("Spine Index #{}: {}", m.spine_index, m.snippet);
}// Generate discrete location chunks (1000 characters per location)
book.generate_locations(1000);
let total_locs = book.locations.total_locations;
let progress = book.locations.percentage_from_location(5);
println!("Total Locations: {}, Progress at loc 5: {:.2}%", total_locs, progress * 100.0);