init
This commit is contained in:
commit
0dc3a6c0f6
11 files changed
+243
No files matched your search
@@ -0,0 +1,55 @@
|
||||
#![allow(unused)]
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
struct CredentialManager {
|
||||
locked: bool,
|
||||
entries: HashMap<String, String>,
|
||||
}
|
||||
|
||||
impl CredentialManager {
|
||||
pub fn new() -> CredentialManager {
|
||||
CredentialManager {
|
||||
locked: false,
|
||||
entries: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unlock(&self, master_secret: &str) -> Result<(), &'static str> {
|
||||
if !self.locked {
|
||||
return Err("already unlocked");
|
||||
}
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn set(&mut self, key: &str, secret: &str) -> Result<(), &'static str> {
|
||||
if self.locked {
|
||||
return Err("locked");
|
||||
}
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn get(&mut self, key: &str) -> Result<Option<&str>, &'static str> {
|
||||
if self.locked {
|
||||
return Err("locked");
|
||||
}
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn lock(&self) -> Result<(), &'static str> {
|
||||
if self.locked {
|
||||
return Err("already locked");
|
||||
}
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<(), &'static str> {
|
||||
let mut pw = CredentialManager::new();
|
||||
pw.unlock("pssst")?;
|
||||
pw.set("foo", "bar")?;
|
||||
let val = pw.get("foo")?;
|
||||
pw.lock()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user