25 releases

0.7.0 Jan 8, 2022
0.6.0 Oct 31, 2021
0.5.1 Dec 7, 2020
0.5.0 Nov 22, 2020
0.2.4 Sep 2, 2019

#182 in Parser implementations

Download history 67/week @ 2022-01-28 1/week @ 2022-02-04 2/week @ 2022-02-11 27/week @ 2022-02-18 1/week @ 2022-02-25 2/week @ 2022-03-04 84/week @ 2022-03-11 101/week @ 2022-03-18 3/week @ 2022-03-25 1/week @ 2022-04-01 5/week @ 2022-04-08 4/week @ 2022-04-15 84/week @ 2022-04-22 153/week @ 2022-04-29 130/week @ 2022-05-06 426/week @ 2022-05-13

793 downloads per month

MIT license

125KB
2.5K 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.7"
  • 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

~3.5MB
~59K SLoC