rbook

A fast, format-agnostic, ergonomic ebook library with a focus on EPUB.
The primary goal of rbook is to provide an easy-to-use high-level API for handling and editing ebooks.
Most importantly, this library is designed with future formats in mind
(CBZ, FB2, MOBI, etc.) via core traits defined within the ebook
and reader module, allowing all formats to share the same "base" API.
Documentation
Features
Here is a non-exhaustive list of the features rbook provides:
| Feature | Overview | Documentation |
|---|---|---|
| EPUB 2 and 3 | Simple and advanced read/write view of EPUB 2 and 3 formats. |
epub module |
| Reader | Random‐access or sequential iteration over readable content. | reader module |
| Detailed Types | Abstractions built on expressive traits and types. | |
| Metadata | Typed access to dates, titles, creators, publishers, languages, tags, roles, attributes, and more. | metadata module |
| Manifest | Lookup and traverse contained resources such as readable content (XHTML) and images. | manifest module |
| Spine | Chronological reading order and preferred page direction. | spine module |
| Table of Contents (ToC) | Navigation points, including the EPUB 2 guide and EPUB 3 landmarks. | toc module |
| Resources | On-demand retrieval of bytes or strings for any manifest resource; data is not loaded up-front until requested. | resource module |
Default crate features
These are toggleable features for rbook that are
enabled by default in a project's Cargo.toml file:
| Feature | Description |
|---|---|
| write | Creation and modification of EPUB 2 and 3 formats. |
| prelude | Convenience prelude only including common traits. |
| threadsafe | Enables Send + Sync constraint for Epub. |
Usage
rbook can be used by adding it as a dependency in a project's Cargo.toml file:
[]
= "0.7.0" # With default features
# rbook = { version = "0.7.0", default-features = false } # Excluding default features
WebAssembly
The wasm32-unknown-unknown target is supported by default.
Examples
Opening and reading an EPUB file
use Epub;
Accessing metadata: Retrieving the main title
use Epub;
use ;
Accessing metadata: Retrieving the year and first creator
use Epub;
use LanguageKind;
Extracting images from the manifest
use Epub;
use ;
use Path;
Editing an EPUB
use Epub;
use EbookResult;
Creating a backwards-compatible EPUB 3 file
This example uses the high-level builder API.
See the epub module for lower-level control over the manifest, spine, etc.
use Epub;
use EbookResult;
use TocEntryKind;
use EpubChapter;
use Path;
const XHTML: & = b"<xhtml>...</xhtml>"; // Example data
[!TIP] More examples are available in the documentation: https://docs.rs/rbook
MSRV
The current Minimum Supported Rust Version is 1.88.0.
License
Licensed under Apache License, Version 2.0.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.