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) -> CustomApiKeyStorage
pub fn new(provider: &str) -> CustomApiKeyStorage
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<CustomApiKeyStorage, Error>
pub fn for_provider_key( provider: &str, key_name: &str, ) -> Result<CustomApiKeyStorage, Error>
Create storage scoped to a provider and credential key name.
Sourcepub fn for_identity(
identity: CredentialIdentity,
) -> Result<CustomApiKeyStorage, Error>
pub fn for_identity( identity: CredentialIdentity, ) -> Result<CustomApiKeyStorage, Error>
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<(), Error>
pub fn store( &self, api_key: &str, mode: AuthCredentialsStoreMode, ) -> Result<(), Error>
Store an API key securely.
Sourcepub fn load(
&self,
mode: AuthCredentialsStoreMode,
) -> Result<Option<String>, Error>
pub fn load( &self, mode: AuthCredentialsStoreMode, ) -> Result<Option<String>, Error>
Retrieve a stored API key.
Sourcepub fn load_with_legacy_fallback(
&self,
mode: AuthCredentialsStoreMode,
allow_legacy: bool,
) -> Result<Option<String>, Error>
pub fn load_with_legacy_fallback( &self, mode: AuthCredentialsStoreMode, allow_legacy: bool, ) -> Result<Option<String>, Error>
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<(), Error>
pub fn clear(&self, mode: AuthCredentialsStoreMode) -> Result<(), Error>
Clear (delete) a stored API key.
Sourcepub fn clear_with_legacy_fallback(
&self,
mode: AuthCredentialsStoreMode,
clear_legacy: bool,
) -> Result<(), Error>
pub fn clear_with_legacy_fallback( &self, mode: AuthCredentialsStoreMode, clear_legacy: bool, ) -> Result<(), Error>
Clear this key-scoped credential and optionally its provider-only legacy fallback.