📖
ebook-rs v0.18.6
⚡ Pure Rust 2024 • AI RAG Engine • C FFI & WASM SDK • 11 Formats

High-Performance Engine for 11 eBook & Document Formats

Pure Rust engine for EPUB, MOBI, AZW3, FB2, KEPUB, LIT, CBZ, PDF, ODT, TXT, and Markdown with Native AI RAG Chunking, C/Python FFI, Web Component, and Readium APIs.

Add to Cargo.toml Try Live Reader Demo
EPUB 2/3
AZW3/MOBI
FB2
CBZ
PDF
ODT
Markdown/TXT
samples/Alice in Wonderland - Lewis Carroll EPUB2.epub

Chapter I: Down the Rabbit-Hole

Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice 'without pictures or conversations?'

So she was considering in her own mind whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.

Built for Performance & Parity

Designed to deliver 100% feature parity with epub.js and foliate-js in native Rust and WebAssembly.

⚡

0-Allocation Full-Text Search

Pre-computed lowercase section caches allow searching millions of characters in under 1 millisecond.

📚

Multi-Format Parser Engine

Native parsers for EPUB 2/3, MOBI, AZW3 (KF8), FictionBook 2 (FB2), KEPUB, and Microsoft Reader (LIT).

📍

Complete IDPF CFI Engine

Canonical Fragment Identifier parsing, range calculations, and character position ordering.

🔒

IDPF & Adobe Font De-Obfuscation

Native SHA-1 key calculation and XOR byte transformations for protected font files.

🌐

WebAssembly & Reader Server

Supports `wasm-bindgen` for browser web apps and includes a built-in multithreaded HTTP reader server.

🖼️

Automatic Base64 Inlining

Inlines CSS stylesheets and images into self-contained HTML strings without external blob URIs.

Simple & Intuitive API

Load any eBook format with auto-detection in 2 lines of code.

Basic Usage
Full-Text Search
WASM Bindings
use ebook_rs::Book;

fn main() -> Result<(), String> {
    // Auto-detects EPUB, MOBI, AZW3, FB2, KEPUB, or LIT from path
    let mut book = Book::from_file("alice.azw3")?;

    println!("Title: {}", book.metadata().title);
    println!("Total Sections: {}", book.spine().len());

    // Search full-text across chapters
    let matches = book.search("Rabbit");
    println!("Found {} search matches", matches.len());

    Ok(())
}