CredentialStoreApi

Trait CredentialStoreApi 

Source
pub trait CredentialStoreApi {
    // Required methods
    fn vendor(&self) -> String;
    fn id(&self) -> String;
    fn build(
        &self,
        service: &str,
        user: &str,
        modifiers: Option<&HashMap<&str, &str>>,
    ) -> Result<Entry>;
    fn as_any(&self) -> &dyn Any;

    // Provided methods
    fn search(&self, _spec: &HashMap<&str, &str>) -> Result<Vec<Entry>> { ... }
    fn persistence(&self) -> CredentialPersistence { ... }
    fn debug_fmt(&self, f: &mut Formatter<'_>) -> Result { ... }
}
Expand description

The API that credential stores implement.

Required Methods§

Source

fn vendor(&self) -> String

The name of the “vendor” that provides this store.

This allows clients to conditionalize their code for specific vendors. This string should not vary with versions of the store. It’s recommended that it include the crate URL for the module provider.

Source

fn id(&self) -> String

The ID of this credential store instance.

IDs need not be unique across vendors or processes, but they serve as instance IDs within a process. If two credential store instances in a process have the same vendor and id, then they are the same instance.

It’s recommended that this include the version of the provider.

Source

fn build( &self, service: &str, user: &str, modifiers: Option<&HashMap<&str, &str>>, ) -> Result<Entry>

Create an entry specified by the given service and user, perhaps with additional creation-time modifiers.

The credential returned from this call must be a specifier, meaning that it can be used to create a credential later even if a matching credential existed in the store .

This typically has no effect on the content of the underlying store. A credential need not be persisted until its password is set.

Source

fn as_any(&self) -> &dyn Any

Return the inner store object cast to Any.

This call is used to expose the Debug trait for stores.

Provided Methods§

Source

fn search(&self, _spec: &HashMap<&str, &str>) -> Result<Vec<Entry>>

Search for credentials that match the given spec.

Returns a list of the matching credentials.

Should return an Invalid error if the spec is bad.

The default implementation returns a NotSupportedByStore error; that is, credential stores need not provide support for search.

Source

fn persistence(&self) -> CredentialPersistence

The lifetime of credentials produced by this builder.

A default implementation is provided for backward compatibility, since this API was added in a minor release. The default assumes that keystores use disk-based credential storage.

Source

fn debug_fmt(&self, f: &mut Formatter<'_>) -> Result

The Debug trait call for the object.

This is used to implement the Debug trait on this type; it allows generic code to provide debug printing as provided by the underlying concrete object.

We provide a (no-op) default implementation of this method.

Implementors§

Source§

impl CredentialStoreApi for keyring_core::mock::Store

Source§

impl CredentialStoreApi for keyring_core::sample::store::Store