pub struct Entry { /* private fields */ }
Expand description
A named entry in a credential store.
Implementations§
Source§impl Entry
impl Entry
Sourcepub fn new(service: &str, user: &str) -> Result<Entry>
pub fn new(service: &str, user: &str) -> Result<Entry>
Create an entry for the given service
and user
.
The default credential builder is used.
§Errors
Returns an Invalid error
if the service
or user
values are not
acceptable to the default credential store.
Returns a NoDefaultStore error if the default credential store has not been set.
Sourcepub fn new_with_modifiers(
service: &str,
user: &str,
modifiers: &HashMap<&str, &str>,
) -> Result<Entry>
pub fn new_with_modifiers( service: &str, user: &str, modifiers: &HashMap<&str, &str>, ) -> Result<Entry>
Create an entry for the given service
and user
, passing store-specific modifiers.
The default credential builder is used.
See the documentation for each credential store to understand what modifiers may be specified for that store.
§Errors
Returns an Invalid error
if the service
, user
, or modifier
pairs are not
acceptable to the default credential store.
Returns a NoDefaultStore error if the default credential store has not been set.
Sourcepub fn new_with_credential(credential: Arc<Credential>) -> Entry
pub fn new_with_credential(credential: Arc<Credential>) -> Entry
Create an entry that wraps a pre-existing credential. The credential can be from any credential store.
Sourcepub fn search(spec: &HashMap<&str, &str>) -> Result<Vec<Entry>>
pub fn search(spec: &HashMap<&str, &str>) -> Result<Vec<Entry>>
Search for credentials, returning entries that wrap any found.
The default credential store is searched. See the documentation of each credential store for how searches are specified.
§Errors
Returns an Invalid error
if the spec
value is not acceptable to the default credential store.
Returns a NoDefaultStore error if the default credential store has not been set.
Sourcepub fn set_password(&self, password: &str) -> Result<()>
pub fn set_password(&self, password: &str) -> Result<()>
Set the password for this entry.
If a credential for this entry already exists in the store, this will update its password. Otherwise, a new credential will be created to store the password.
§Errors
If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.
If this entry is a wrapper, and the underlying credential has been deleted, may return a NoEntry error.
If a credential cannot store the given password (not all stores support empty passwords, and some have length limits), then an Invalid error is returned.
Sourcepub fn set_secret(&self, secret: &[u8]) -> Result<()>
pub fn set_secret(&self, secret: &[u8]) -> Result<()>
Set the secret for this entry.
If a credential for this entry already exists in the store, this will update its secret. Otherwise, a new credential will be created to store the secret.
§Errors
If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.
If this entry is a wrapper, and the underlying credential has been deleted, may return a NoEntry error.
If a credential cannot store the given password (not all stores support empty passwords, and some have length limits), then an Invalid error is returned.
Sourcepub fn get_password(&self) -> Result<String>
pub fn get_password(&self) -> Result<String>
Retrieve the password saved for this entry.
§Errors
If this entry is a specifier, and there is no matching credential in the store, returns a NoEntry error.
If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.
If this entry is a wrapper, the underlying credential has been deleted, and the store cannot recreate it, returns a NoEntry error.
Will return a BadEncoding error containing the data as a byte array if the password is not a valid UTF-8 string.
Sourcepub fn get_secret(&self) -> Result<Vec<u8>>
pub fn get_secret(&self) -> Result<Vec<u8>>
Retrieve the secret saved for this entry.
§Errors
If this entry is a specifier, and there is no matching credential in the store, returns a NoEntry error.
If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.
If this entry is a wrapper, and the underlying credential has been deleted, returns a NoEntry error.
Sourcepub fn get_attributes(&self) -> Result<HashMap<String, String>>
pub fn get_attributes(&self) -> Result<HashMap<String, String>>
Get the store-specific decorations on this entry’s credential.
See the documentation for each credential store for details of what decorations are supported and how they are returned.
§Errors
If this entry is a specifier, and there is no matching credential in the store, returns a NoEntry error.
If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.
If this entry is a wrapper, and the underlying credential has been deleted, returns a NoEntry error.
Sourcepub fn update_attributes(&self, attributes: &HashMap<&str, &str>) -> Result<()>
pub fn update_attributes(&self, attributes: &HashMap<&str, &str>) -> Result<()>
Update the store-specific decorations on this entry’s credential.
See the documentation for each credential store for details of what decorations can be updated and how updates are expressed.
§Errors
If one of the attributes supplied is not valid for the underlying store, returns an Invalid error.
If this entry is a specifier, and there is no matching credential in the store, returns a NoEntry error.
If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.
If this entry is a wrapper, and the underlying credential has been deleted, returns a NoEntry error.
Sourcepub fn delete_credential(&self) -> Result<()>
pub fn delete_credential(&self) -> Result<()>
Delete the matching credential for this entry.
This call does not affect the lifetime of the Entry structure, only that of the underlying credential.
§Errors
If this entry is a specifier, and there is no matching credential in the store, returns a NoEntry error.
If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.
If this entry is a wrapper, and the underlying credential has been deleted, returns a NoEntry error.
Sourcepub fn get_credential(&self) -> Result<Entry>
pub fn get_credential(&self) -> Result<Entry>
Get a wrapper for the currently matching credential.
§Errors
If this entry is a specifier, and there is no matching credential in the store, returns a NoEntry error.
If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.
If this entry is a wrapper, and the underlying credential has been deleted, returns a NoEntry error.
Sourcepub fn get_specifiers(&self) -> Option<(String, String)>
pub fn get_specifiers(&self) -> Option<(String, String)>
Get the <service, user>
pair for this entry, if any.