pub struct ChainStore { /* private fields */ }Expand description
Composable credential store that chains multiple backends.
Attempts to retrieve credentials from each store in order until one succeeds. Write operations go to the first writable store.
§Default Chain
Use ChainStore::default_chain() for the recommended configuration:
- Environment variables (highest priority, for CI/CD)
- OS Keychain (for local development)
§Example
ⓘ
use devboy_storage::{ChainStore, CredentialStore};
// Use default chain
let store = ChainStore::default_chain();
// Or create custom chain
use devboy_storage::{EnvVarStore, MemoryStore};
let store = ChainStore::new(vec![
Box::new(EnvVarStore::new()),
Box::new(MemoryStore::new()),
]);Implementations§
Source§impl ChainStore
impl ChainStore
Sourcepub fn new(stores: Vec<Box<dyn CredentialStore>>) -> Self
pub fn new(stores: Vec<Box<dyn CredentialStore>>) -> Self
Create a chain store from a list of stores.
Stores are tried in order for read operations. The first writable store is used for write operations.
Sourcepub fn default_chain() -> Self
pub fn default_chain() -> Self
Create the default credential chain.
Order:
- Environment variables (
EnvVarStore) - OS Keychain (
KeychainStore)
This is the recommended configuration for most use cases:
- CI/CD can set
DEVBOY_*or provider-specific env vars - Local development uses keychain transparently
Trait Implementations§
Source§impl CredentialStore for ChainStore
impl CredentialStore for ChainStore
Source§fn store(&self, key: &str, value: &SecretString) -> Result<()>
fn store(&self, key: &str, value: &SecretString) -> Result<()>
Store a credential securely. Read more
Source§fn get(&self, key: &str) -> Result<Option<SecretString>>
fn get(&self, key: &str) -> Result<Option<SecretString>>
Retrieve a stored credential. Read more
Source§fn is_available(&self) -> bool
fn is_available(&self) -> bool
Check if this credential store is available and functional. Read more
Source§fn is_writable(&self) -> bool
fn is_writable(&self) -> bool
Check if this store supports write operations. Read more
Auto Trait Implementations§
impl Freeze for ChainStore
impl !RefUnwindSafe for ChainStore
impl Send for ChainStore
impl Sync for ChainStore
impl Unpin for ChainStore
impl UnsafeUnpin for ChainStore
impl !UnwindSafe for ChainStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more