pub struct Entry { /* private fields */ }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
This function will return an Error if the service or user values are invalid.
The specific reasons for invalidity are platform-dependent, but include length constraints.
§Panics
In the very unlikely event that the internal credential builder’s `RwLock`` is poisoned, this function will panic. If you encounter this, and especially if you can reproduce it, please report a bug with the details (and preferably a backtrace) so the developers can investigate.
Sourcepub fn new_with_target(target: &str, service: &str, user: &str) -> Result<Entry>
pub fn new_with_target(target: &str, service: &str, user: &str) -> Result<Entry>
Create an entry for the given target, service, and user.
The default credential builder is used.
Sourcepub fn new_with_credential(credential: Box<Credential>) -> Entry
pub fn new_with_credential(credential: Box<Credential>) -> Entry
Create an entry that uses the given platform credential for storage.
Sourcepub fn set_password(&self, password: &str) -> Result<()>
pub fn set_password(&self, password: &str) -> Result<()>
Set the password for this entry.
Can return an Ambiguous error if there is more than one platform credential that matches this entry. This can only happen on some platforms, and then only if a third-party application wrote the ambiguous credential.
Sourcepub fn set_secret(&self, secret: &[u8]) -> Result<()>
pub fn set_secret(&self, secret: &[u8]) -> Result<()>
Set the secret for this entry.
Can return an Ambiguous error if there is more than one platform credential that matches this entry. This can only happen on some platforms, and then only if a third-party application wrote the ambiguous credential.
Sourcepub fn get_password(&self) -> Result<String>
pub fn get_password(&self) -> Result<String>
Retrieve the password saved for this entry.
Returns a NoEntry error if there isn’t one.
Can return an Ambiguous error if there is more than one platform credential that matches this entry. This can only happen on some platforms, and then only if a third-party application wrote the ambiguous credential.
Sourcepub fn get_secret(&self) -> Result<Vec<u8>>
pub fn get_secret(&self) -> Result<Vec<u8>>
Retrieve the secret saved for this entry.
Returns a NoEntry error if there isn’t one.
Can return an Ambiguous error if there is more than one platform credential that matches this entry. This can only happen on some platforms, and then only if a third-party application wrote the ambiguous credential.
Sourcepub fn get_attributes(&self) -> Result<HashMap<String, String>>
pub fn get_attributes(&self) -> Result<HashMap<String, String>>
Get the attributes on the underlying credential for this entry.
Some of the underlying credential stores allow credentials to have named attributes that can be set to string values. See the documentation for each credential store for a list of which attribute names are supported by that store.
Returns a NoEntry error if there isn’t a credential for this entry.
Can return an Ambiguous error if there is more than one platform credential that matches this entry. This can only happen on some platforms, and then only if a third-party application wrote the ambiguous credential.
Sourcepub fn update_attributes(&self, attributes: &HashMap<&str, &str>) -> Result<()>
pub fn update_attributes(&self, attributes: &HashMap<&str, &str>) -> Result<()>
Update the attributes on the underlying credential for this entry.
Some of the underlying credential stores allow credentials to have named attributes that can be set to string values. See the documentation for each credential store for a list of which attribute names can be given values by this call. To support cross-platform use, each credential store ignores (without error) any specified attributes that aren’t supported by that store.
Returns a NoEntry error if there isn’t a credential for this entry.
Can return an Ambiguous error if there is more than one platform credential that matches this entry. This can only happen on some platforms, and then only if a third-party application wrote the ambiguous credential.
Sourcepub fn delete_credential(&self) -> Result<()>
pub fn delete_credential(&self) -> Result<()>
Delete the underlying credential for this entry.
Returns a NoEntry error if there isn’t one.
Can return an Ambiguous error if there is more than one platform credential that matches this entry. This can only happen on some platforms, and then only if a third-party application wrote the ambiguous credential.
Note: This does not affect the lifetime of the Entry structure, which is controlled by Rust. It only affects the underlying credential store.
Sourcepub fn get_credential(&self) -> &dyn Any
pub fn get_credential(&self) -> &dyn Any
Return a reference to this entry’s wrapped credential.
The reference is of the Any type, so it can be downgraded to a concrete credential object. The client must know what type of concrete object to cast to.