passgen-rs 0.1.0

Password generator with a regular-expression-like syntax
Documentation
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};

#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Config {
    pub wordlists: BTreeMap<String, PathBuf>,
    pub presets: BTreeMap<String, String>,
}

impl Config {
    pub fn wordlist_add<S: Into<String>, P: Into<PathBuf>>(&mut self, name: S, path: P) {
        self.wordlists.insert(name.into(), path.into());
    }

    pub fn wordlist_path(&self, name: &str) -> Option<&Path> {
        self.wordlists.get(name).map(|p| p.as_path())
    }
}