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§
Sourcefn vendor(&self) -> String
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.
Sourcefn id(&self) -> String
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.
Sourcefn build(
&self,
service: &str,
user: &str,
modifiers: Option<&HashMap<&str, &str>>,
) -> Result<Entry>
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.
Provided Methods§
Sourcefn search(&self, _spec: &HashMap<&str, &str>) -> Result<Vec<Entry>>
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.
Sourcefn persistence(&self) -> CredentialPersistence
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.
Sourcefn debug_fmt(&self, f: &mut Formatter<'_>) -> Result
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.