passgen/
config.rs

1use serde::{Deserialize, Serialize};
2use std::collections::BTreeMap;
3use std::path::{Path, PathBuf};
4
5#[derive(Clone, Debug, Default, Serialize, Deserialize)]
6pub struct Config {
7    pub wordlists: BTreeMap<String, PathBuf>,
8    pub presets: BTreeMap<String, String>,
9}
10
11impl Config {
12    pub fn wordlist_add<S: Into<String>, P: Into<PathBuf>>(&mut self, name: S, path: P) {
13        self.wordlists.insert(name.into(), path.into());
14    }
15
16    pub fn wordlist_path(&self, name: &str) -> Option<&Path> {
17        self.wordlists.get(name).map(|p| p.as_path())
18    }
19}