1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
use serde_derive::Deserialize;
use std::collections::HashMap;
use super::{parse_to_config_file, TomlConfigFile};
#[derive(Debug, Deserialize)]
pub struct JoshutoPreviewEntry {
pub program: String,
pub args: Option<Vec<String>>,
}
#[derive(Debug, Default, Deserialize)]
struct JoshutoPreviewRaw {
pub extension: Option<HashMap<String, JoshutoPreviewEntry>>,
pub mimetype: Option<HashMap<String, JoshutoPreviewEntry>>,
}
impl From<JoshutoPreviewRaw> for JoshutoPreview {
fn from(crude: JoshutoPreviewRaw) -> Self {
let extension = crude.extension.unwrap_or_default();
let mimetype = crude.mimetype.unwrap_or_default();
Self {
extension,
mimetype,
}
}
}
#[derive(Debug, Default)]
pub struct JoshutoPreview {
pub extension: HashMap<String, JoshutoPreviewEntry>,
pub mimetype: HashMap<String, JoshutoPreviewEntry>,
}
impl TomlConfigFile for JoshutoPreview {
fn get_config(file_name: &str) -> Self {
parse_to_config_file::<JoshutoPreviewRaw, JoshutoPreview>(file_name).unwrap_or_default()
}
}
|