Expand description
Convert books between mbook and other formats.
One type does the work: Converter. It takes a source as any
Read or as a byte slice, and gives an mbook file
written to any Write, or a Book
that can still be changed.
The optional export feature writes an existing book in another format.
use mbook_converter::Converter;
use std::fs::File;
use std::io::BufWriter;
let source = File::open("book.fb2")?;
let sink = BufWriter::new(File::create("book.mbook")?);
let report = Converter::new().convert(source, sink)?;
println!("converted from {}", report.format);
for warning in &report.warnings {
eprintln!("{warning}");
}The design is described in the docs/src/mbook-converter folder of the
repository.
§Features
Each import format has a feature enabled by default.
| Feature | Format |
|---|---|
epub | EPUB 2 and 3 |
fb2 | FictionBook 2, plain or inside a ZIP |
pdf | |
cbz | Comic book archive |
docx | Word documents |
html | One HTML document |
md | One Markdown document |
txt | Plain text |
A source in a format whose feature is disabled is still recognised and
refused with Error::FormatDisabled.
The opt-in rayon feature encodes the pictures of a source on all cores
at once instead of one after another. The book is the same.
The opt-in export feature enables writing all eight formats, including
their picture codecs, and figure, which draws the diagrams and
formulas of a book. It currently requires Rust 1.98 or later.
Re-exports§
pub use mbook;
Structs§
- Convert
Limits - Bounds applied before memory is reserved for something a source declares.
- Convert
Options - How a source is converted. Start from
ConvertOptions::defaultand change the fields that matter. - Converted
- A converted book that can still be changed, and what its conversion reported.
- Converter
- Converts books between mbook and other formats.
- Picture
Options - How pictures are encoded as AVIF. A value outside its range is brought into the range.
- Report
- What a conversion found out.
- Warning
- One thing a conversion could not keep.
Enums§
- Error
- Why a conversion failed.
- Format
- A supported book format.
- Warning
Kind - What a conversion lost.
Type Aliases§
- Result
- The result type of this crate.