pub struct CustomApiKeyStorage { /* private fields */ }Expand description
Custom API Key storage for provider-specific keys.
Provides secure storage and retrieval of API keys for custom providers using the OS keyring or encrypted file storage.
Implementations§
Source§impl CustomApiKeyStorage
impl CustomApiKeyStorage
Sourcepub fn new(provider: &str) -> Self
pub fn new(provider: &str) -> Self
Create a provider-only legacy storage handle.
New callers should use Self::for_provider_key. This constructor is
retained so older integrations can still read and clear the legacy
api_key_<provider> entry.
Sourcepub fn for_provider_key(provider: &str, key_name: &str) -> Result<Self>
pub fn for_provider_key(provider: &str, key_name: &str) -> Result<Self>
Create storage scoped to a provider and credential key name.
Sourcepub fn for_identity(identity: CredentialIdentity) -> Result<Self>
pub fn for_identity(identity: CredentialIdentity) -> Result<Self>
Create storage scoped to a validated credential identity.
Sourcepub fn identity(&self) -> Option<&CredentialIdentity>
pub fn identity(&self) -> Option<&CredentialIdentity>
Return the identity for a key-scoped handle, or None for a legacy
provider-only handle.
Sourcepub fn store(&self, api_key: &str, mode: AuthCredentialsStoreMode) -> Result<()>
pub fn store(&self, api_key: &str, mode: AuthCredentialsStoreMode) -> Result<()>
Store an API key securely.
Sourcepub fn load(&self, mode: AuthCredentialsStoreMode) -> Result<Option<String>>
pub fn load(&self, mode: AuthCredentialsStoreMode) -> Result<Option<String>>
Retrieve a stored API key.
Sourcepub fn load_with_legacy_fallback(
&self,
mode: AuthCredentialsStoreMode,
allow_legacy: bool,
) -> Result<Option<String>>
pub fn load_with_legacy_fallback( &self, mode: AuthCredentialsStoreMode, allow_legacy: bool, ) -> Result<Option<String>>
Load a key-scoped credential and, when explicitly allowed, lazily migrate the provider-only legacy entry into this identity.
Sourcepub fn clear(&self, mode: AuthCredentialsStoreMode) -> Result<()>
pub fn clear(&self, mode: AuthCredentialsStoreMode) -> Result<()>
Clear (delete) a stored API key.
Sourcepub fn clear_with_legacy_fallback(
&self,
mode: AuthCredentialsStoreMode,
clear_legacy: bool,
) -> Result<()>
pub fn clear_with_legacy_fallback( &self, mode: AuthCredentialsStoreMode, clear_legacy: bool, ) -> Result<()>
Clear this key-scoped credential and optionally its provider-only legacy fallback.