Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

mbook

mbook is a file format for books: chapters in Markdown, pictures in AVIF, and small typed tables that describe the book, all stored as independent OpenZL frames inside one indexed container.

The pairing of OpenZL and AVIF is what makes a book small and quick: an illustrated EPUB of 7.0 MB became an mbook file of 1.6 MB that opens in 80 µs and decodes its text at more than a gigabyte per second. The conditions are in RFC 0001, A converted book.

This site holds the specification of the format and the documentation of the three crates built on it.

PartWhat it isStart at
The formatThe specification every reader and writer is checked against, and the decisions behind itRFC 0001
mbookThe Rust library that reads, edits and writes mbook filesmbook
mbook-converterThe Rust library that turns EPUB, FB2, PDF and five other formats into mbook, and backmbook-converter
mbook-uiThe application: a library of books, a reader and an editormbook-ui

Where to start

If you want to…Read
see what the format gains over EPUB and FB2RFC 0001, Motivation
see what a file contains and how it is openedRFC 0001, guide-level explanation
implement a reader or a writerRFC 0001, reference-level explanation
understand why the format looks this wayDecision records
read or write books from RustUsing mbook
look up a type or a call of the librarymbook, API reference, or docs.rs
convert a book into mbook, or export oneUsing mbook-converter
know what a conversion keeps and what it dropsConversion rules
read and edit books without writing codeUsing the application
work on the applicationmbook-ui, Architecture
know what is still openUnresolved questions of RFC 0001, and "Settled and open questions" of mbook, mbook-converter and mbook-ui

Two kinds of document

The format is specified; the crates are described.

The formatA crate
DocumentsRFC 0001 and the decision recordsThe pages of mbook, mbook-converter and mbook-ui
SaysWhat a file MUST contain and what a reader MUST do with itWhat the code does today, and why it is built this way
BindsEvery implementation of the format, in any languageThis repository only
A choice between alternatives is recordedAs a decision record (ADR)In the "Rationale and alternatives" table of the crate's Design page
ChangesWhen the format changesWith the code, in the same change

An RFC specifies behaviour: it is what an implementation is checked against. A decision record explains one choice the RFC makes: the options that were compared, the trade-off, and what follows from it. The RFC links to the records instead of repeating them.

The pages of a crate are not normative. They describe what exists, mark what is not implemented, and where they say that something "must" hold, they state an invariant of this code that a test or a review keeps. RFC 0002 to RFC 0004, which described the three crates in earlier versions of this site, became these pages; the old addresses lead to them.

Page of a crateWhat it answers
OverviewWhat the crate is, what it is for, its goals and non-goals.
GuideHow each task is done, with its code or its screen.
API reference, Conversion rules, ArchitectureWhat exactly the crate does: its types, its rules, its parts.
DesignIts dependencies, what the design costs, the alternatives that were rejected, and what is still open.

Documents

DocumentTitleStatus
RFC 0001The mbook file format, version 1Draft
ADR-0001 … ADR-0011Decisions behind RFC 0001See the overview
mbookThe library that reads and writes the formatImplements the whole of RFC 0001
mbook-converterImport from eight formats, export to the same eightImplemented; limits per format
mbook-uiThe reading and editing applicationA first version; what is implemented

Outline of an RFC

SectionWhat it answers
SummaryWhat is proposed, in a paragraph.
MotivationWhy the format needs it; goals and non-goals.
Guide-level explanationHow it looks to someone packing or reading a book.
Reference-level explanationThe normative rules an implementation follows.
DrawbacksWhat the design costs.
Rationale and alternativesThe decisions taken, with links to their records.
Prior artRelated formats and what was taken from them.
Unresolved questionsWhat must be settled before the RFC is accepted.
Future possibilitiesWhat the design leaves room for.

Reading the normative text

The key words MUST, MUST NOT, REQUIRED, SHOULD, SHOULD NOT, RECOMMENDED, MAY and OPTIONAL are to be interpreted as described in RFC 2119 and RFC 8174 when, and only when, they appear in capitals. They are used in the Reference-level explanation of an RFC and nowhere else: everything outside that section, and every page of a crate, is informative.

Building this site

The site is an mdBook in the docs folder of the repository, with mdbook-mermaid for the diagrams. It is published to GitHub Pages from the main branch.

Extract the diagram scripts once:

mdbook-mermaid install docs

Then serve the book with live reload:

mdbook serve docs --open

The HTML is written to target/book.