verso-reader 0.1.0

A terminal EPUB reader with vim navigation, a Kindle-style library, and Markdown highlight export
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::Config;
use std::path::Path;

pub fn from_path(path: &Path) -> anyhow::Result<Config> {
    if !path.exists() {
        return Ok(Config::default());
    }
    let text = std::fs::read_to_string(path)?;
    let cfg: Config =
        toml::from_str(&text).map_err(|e| anyhow::anyhow!("parsing {}: {}", path.display(), e))?;
    Ok(cfg)
}

/// Deserialise from a TOML string. Used by tests.
pub fn from_str(s: &str) -> anyhow::Result<Config> {
    Ok(toml::from_str(s)?)
}