Skip to main content

ai_agent/utils/
secure_storage.rs

1//! Secure storage utilities.
2
3use std::collections::HashMap;
4
5/// Secure storage for sensitive data
6pub struct SecureStorage {
7    data: HashMap<String, Vec<u8>>,
8}
9
10impl SecureStorage {
11    pub fn new() -> Self {
12        Self {
13            data: HashMap::new(),
14        }
15    }
16
17    /// Store a value
18    pub fn set(&mut self, key: &str, value: Vec<u8>) {
19        self.data.insert(key.to_string(), value);
20    }
21
22    /// Retrieve a value
23    pub fn get(&self, key: &str) -> Option<Vec<u8>> {
24        self.data.get(key).cloned()
25    }
26
27    /// Check if a key exists
28    pub fn has(&self, key: &str) -> bool {
29        self.data.contains_key(key)
30    }
31
32    /// Delete a value
33    pub fn delete(&mut self, key: &str) -> Option<Vec<u8>> {
34        self.data.remove(key)
35    }
36
37    /// Clear all values
38    pub fn clear(&mut self) {
39        self.data.clear();
40    }
41}
42
43impl Default for SecureStorage {
44    fn default() -> Self {
45        Self::new()
46    }
47}