ic_auth_client/storage/
sync_storage.rs

1//! Storage implementations for authentication client data.
2//!
3//! This module provides keyring and filesystem-based storage for secure credential management.
4
5use crate::storage::{StorageError, StoredKey};
6
7#[cfg(feature = "keyring")]
8pub mod keyring;
9#[cfg(feature = "pem")]
10pub mod pem;
11
12#[cfg(feature = "keyring")]
13pub use keyring::KeyringStorage;
14#[cfg(feature = "pem")]
15pub use pem::PemStorage;
16
17/// Trait for persisting user authentication data.
18pub trait AuthClientStorage: Send {
19    /// Retrieves a stored value by key.
20    ///
21    /// # Arguments
22    /// * `key` - The key to look up in storage
23    ///
24    /// # Returns
25    /// * `Ok(Some(StoredKey))` if the key exists in storage
26    /// * `Ok(None)` if the key does not exist
27    /// * `Err(StorageError)` if an error occurred
28    fn get(&mut self, key: &str) -> Result<Option<StoredKey>, StorageError>;
29
30    /// Stores a key-value pair in the storage.
31    ///
32    /// # Arguments
33    /// * `key` - The key to store the value under
34    /// * `value` - The value to store
35    ///
36    /// # Returns
37    /// * `Ok(())` if the value was successfully stored
38    /// * `Err(StorageError)` if an error occurred during storage
39    fn set(&mut self, key: &str, value: StoredKey) -> Result<(), StorageError>;
40
41    /// Removes a stored value by key.
42    ///
43    /// # Arguments
44    /// * `key` - The key to remove from storage
45    ///
46    /// # Returns
47    /// * `Ok(())` if the key was successfully removed
48    /// * `Err(StorageError)` if an error occurred during removal
49    fn remove(&mut self, key: &str) -> Result<(), StorageError>;
50}