26 releases

0.8.0 Dec 11, 2022
0.7.0 Jan 8, 2022
0.6.0 Oct 31, 2021
0.5.1 Dec 7, 2020
0.2.4 Sep 2, 2019

#1141 in Parser implementations

Download history 39/week @ 2024-06-17 22/week @ 2024-06-24 9/week @ 2024-07-01 16/week @ 2024-07-08 18/week @ 2024-07-15 36/week @ 2024-07-22 21/week @ 2024-07-29 29/week @ 2024-08-05 24/week @ 2024-08-12 22/week @ 2024-08-19 32/week @ 2024-08-26 23/week @ 2024-09-02 29/week @ 2024-09-09 27/week @ 2024-09-16 95/week @ 2024-09-23 47/week @ 2024-09-30

202 downloads per month
Used in kindle2cbz

MIT license

155KB
3K SLoC

mobi-rs

Build Status crates.io crates.io Docs
A crate to work with MOBI format ebooks.

Usage

  • add to Cargo.toml
[dependencies]
mobi = "0.8"
  • main.rs
use mobi::{Mobi, MobiError};
fn main() -> Result<(), MobiError> {
    let book = vec![0, 0, 0];
    // You can either create a Mobi struct from a slice
    let m = Mobi::new(&book)?;
    // Or from an instance of io::Read
    let stdin = std::io::stdin();
    let mut handle = stdin.lock();
    let m = Mobi::from_read(&mut handle)?;
    // Or from filesystem
    let m = Mobi::from_path("/some/path/to/book.mobi")?;

    // Access metadata
    let title = m.title();
    let author = m.author().unwrap_or_default();
    let publisher = m.publisher().unwrap_or_default();
    let desc = m.description().unwrap_or_default();
    let isbn = m.isbn().unwrap_or_default();
    let pub_date = m.publish_date().unwrap_or_default();
    let contributor = m.contributor().unwrap_or_default();

    // Access Headers
    let metadata = &m.metadata;
    let header = &metadata.header; // Normal Header
    let pdheader = &metadata.palmdoc; // PalmDOC Header
    let mheader = &metadata.mobi; // MOBI Header
    let exth = &metadata.exth; // Extra Header

    // Access content
    let content = m.content_as_string();

    Ok(())
}

License

The MIT License (MIT)

Thanks to

kroo for inspiration and idea.

Dependencies

~4MB
~68K SLoC