blob: 370fef22100f0eb0ca629fbad028d2fb8fdd7106 (
plain)
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
|
use termion::event::Event;
use std::collections::HashMap;
use crate::config::raw::bookmarks::BookmarksRaw;
use crate::config::TomlConfigFile;
use crate::util::keyparse;
use crate::config::parse_config_or_default;
pub type Bookmarks = HashMap<Event, String>;
impl TomlConfigFile for Bookmarks {
fn get_config(file_name: &str) -> Self {
parse_config_or_default::<BookmarksRaw, Bookmarks>(file_name)
}
}
impl From<BookmarksRaw> for Bookmarks {
fn from(raw: BookmarksRaw) -> Self {
let mut raw = raw;
let map: Bookmarks = raw
.bookmark
.drain(..)
.filter_map(|bookmark| match keyparse::str_to_event(&bookmark.key) {
Some(event) => Some((event, bookmark.path)),
None => None,
})
.collect();
map
}
}
|