Skip to main content

CredentialStore

Trait CredentialStore 

Source
pub trait CredentialStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn get<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        service: &'life1 str,
        account: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<SecretString, CredentialError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn set<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        service: &'life1 str,
        account: &'life2 str,
        secret: SecretString,
    ) -> Pin<Box<dyn Future<Output = Result<(), CredentialError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn delete<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        service: &'life1 str,
        account: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), CredentialError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Backend-agnostic contract for credential storage.

Every method is async because some real backends (particularly the platform keyring on Windows and macOS) perform blocking system calls; wrapping in spawn_blocking keeps the trait usable in any async context.

Required Methods§

Source

fn get<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, service: &'life1 str, account: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<SecretString, CredentialError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Retrieve a secret by service/account. Returns CredentialError::NotFound when the store does not carry it.

Source

fn set<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, service: &'life1 str, account: &'life2 str, secret: SecretString, ) -> Pin<Box<dyn Future<Output = Result<(), CredentialError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store (or overwrite) a secret at service/account. Returns CredentialError::ReadOnly on stores that do not support mutation.

Source

fn delete<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, service: &'life1 str, account: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), CredentialError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Remove a secret. Missing entries are not an error. Returns CredentialError::ReadOnly on stores that do not support mutation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§