Skip to main content

verso/config/
schema.rs

1use serde::{Deserialize, Serialize};
2use std::collections::BTreeMap;
3
4#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
5#[serde(default)]
6pub struct Config {
7    pub library: Library,
8    pub reader: Reader,
9    /// action -> one or more key sequences
10    pub keymap: BTreeMap<String, Vec<String>>,
11}
12
13#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
14#[serde(default)]
15pub struct Library {
16    pub path: String,
17    pub export_subdir: String,
18    pub watch: bool,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
22#[serde(default)]
23pub struct Reader {
24    pub column_width: u16,
25    pub theme: String,
26    pub chrome: String,
27    pub chrome_idle_ms: u64,
28    pub wpm: u32,
29    pub code_wrap: String,
30    pub min_term_cols: u16,
31    pub min_term_rows: u16,
32}
33
34#[allow(clippy::derivable_impls)]
35impl Default for Config {
36    fn default() -> Self {
37        Self {
38            library: Library::default(),
39            reader: Reader::default(),
40            keymap: BTreeMap::new(),
41        }
42    }
43}
44impl Default for Library {
45    fn default() -> Self {
46        Self {
47            path: "~/Books".into(),
48            export_subdir: "highlights".into(),
49            watch: true,
50        }
51    }
52}
53impl Default for Reader {
54    fn default() -> Self {
55        Self {
56            column_width: 68,
57            theme: "dark".into(),
58            chrome: "autohide".into(),
59            chrome_idle_ms: 3000,
60            wpm: 250,
61            code_wrap: "scroll".into(),
62            min_term_cols: 40,
63            min_term_rows: 10,
64        }
65    }
66}