summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index d592003..2882039 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -39,7 +39,7 @@
* - allow force
*/
-use std::collections::HashSet;
+use std::collections::{HashMap, HashSet};
use std::fs::Metadata;
use std::path::{Path, PathBuf};
@@ -49,9 +49,25 @@ use serde::{Deserialize, Serialize};
use thiserror::Error;
use uuid::Uuid;
-#[derive(Default, Serialize, Deserialize)]
+#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Config {
repositories: HashSet<PathBuf>,
+ passwords: HashMap<String, (Option<String>, String)>,
+ passphrases: HashMap<PathBuf, String>,
+}
+
+impl Config {
+ pub fn username_for_url(&self, url: &str) -> Option<&String> {
+ self.passwords.get(url)?.0.as_ref()
+ }
+
+ pub fn password_for_url(&self, url: &str) -> Option<&String> {
+ Some(&self.passwords.get(url)?.1)
+ }
+
+ pub fn passphrase_for_key(&self, key: &Path) -> Option<&String> {
+ self.passphrases.get(key)
+ }
}
#[derive(Debug, Error)]