pub struct Entry { /* private fields */ }
Implementations§
source§impl Entry
impl Entry
sourcepub fn new(service: &str, username: &str) -> Entry
pub fn new(service: &str, username: &str) -> Entry
Create an entry for the given service and username. This maps to a target credential in the default keychain.
This call never fails, because there is no actual platform access
performed when the credential object is created. But if you specify
empty strings for any of the arguments, any attempt to use the
credential will fail with a NoEntry
error. And if you specify a
string that exceeds platform limits, you will get a TooLong
error.
sourcepub fn new_with_target(target: &str, service: &str, username: &str) -> Entry
pub fn new_with_target(target: &str, service: &str, username: &str) -> Entry
Create an entry for the given target, service, and username. On Linux and Mac, the target is interpreted as naming the collection/keychain to store the credential. On Windows, the target is used directly as the target name of the credential.
This call never fails, because there is no actual platform access
performed when the credential object is created. But if you specify
empty strings for any of the arguments, any attempt to use the
credential will fail with a NoEntry
error. And if you specify a
string that exceeds platform limits, you will get a TooLong
error.
sourcepub fn new_with_credential(target: &PlatformCredential) -> Result<Entry>
pub fn new_with_credential(target: &PlatformCredential) -> Result<Entry>
Create an entry that uses the given credential for storage. Callers can use their own algorithm to produce a platform-specific credential spec for the given service and username and then call this entry with that value.
This call never fails, because there is no actual platform access performed when the credential object is created. But if you specify a platform credential that contains empty or invalid attributes, you may get errors or surprises when attempting to use the credential.
sourcepub fn set_password(&self, password: &str) -> Result<()>
pub fn set_password(&self, password: &str) -> Result<()>
Set the password for this entry. Any other platform-specific annotations are determined by the mapper that was used to create the 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 is there isn’t one.
sourcepub fn get_password_and_credential(
&self
) -> Result<(String, PlatformCredential)>
pub fn get_password_and_credential(
&self
) -> Result<(String, PlatformCredential)>
Retrieve the password and all the other fields set in the platform-specific credential. This allows retrieving metadata on the credential that were saved by external applications.
sourcepub fn delete_password(&self) -> Result<()>
pub fn delete_password(&self) -> Result<()>
Delete the password for this entry. (Although the entry itself follows the Rust structure lifecycle, deleting the password deletes the platform credential from secure storage.)