pub struct PasswordStore {
pub passwords: Vec<PasswordEntry>,
/* private fields */
}Expand description
Represents a complete password store directory
Fields§
§passwords: Vec<PasswordEntry>a list of password files with metadata
Implementations§
Source§impl PasswordStore
impl PasswordStore
Sourcepub fn new(
store_name: &str,
password_store_dir: &Option<PathBuf>,
password_store_signing_key: &Option<String>,
home: &Option<PathBuf>,
style_file: &Option<PathBuf>,
crypto_impl: &CryptoImpl,
own_fingerprint: &Option<[u8; 20]>,
) -> Result<Self>
pub fn new( store_name: &str, password_store_dir: &Option<PathBuf>, password_store_signing_key: &Option<String>, home: &Option<PathBuf>, style_file: &Option<PathBuf>, crypto_impl: &CryptoImpl, own_fingerprint: &Option<[u8; 20]>, ) -> Result<Self>
Constructs a PasswordStore object. If password_store_signing_key is present,
the function verifies that the .gpg-id file is signed correctly
§Errors
If the configuration or the on disk setup is incorrect
Sourcepub fn create(
store_name: &str,
password_store_dir: &Option<PathBuf>,
recipients: &[Recipient],
recipients_as_signers: bool,
home: &Option<PathBuf>,
style_file: &Option<PathBuf>,
) -> Result<Self>
pub fn create( store_name: &str, password_store_dir: &Option<PathBuf>, recipients: &[Recipient], recipients_as_signers: bool, home: &Option<PathBuf>, style_file: &Option<PathBuf>, ) -> Result<Self>
Creates a PasswordStore, including creating directories and initializing the .gpg-id file
§Errors
Returns an Err if the directory exists, no recipients are empty or a full fingerprint
wasn’t specified.
Sourcepub fn get_name(&self) -> &String
pub fn get_name(&self) -> &String
Returns the name of the store, configured to the configuration file
Sourcepub fn get_valid_gpg_signing_keys(&self) -> &Vec<[u8; 20]>
pub fn get_valid_gpg_signing_keys(&self) -> &Vec<[u8; 20]>
Returns a vec with the keys that are allowed to sign the .gpg-id file
Sourcepub fn get_store_path(&self) -> PathBuf
pub fn get_store_path(&self) -> PathBuf
returns the path to the directory where the store is located.
pub fn get_user_home(&self) -> Option<PathBuf>
Sourcepub fn get_style_file(&self) -> Option<PathBuf>
pub fn get_style_file(&self) -> Option<PathBuf>
returns the style file for the store
Sourcepub fn get_crypto(&self) -> &(dyn Crypto + Send)
pub fn get_crypto(&self) -> &(dyn Crypto + Send)
returns the crypto implementation for the store
pub fn repo(&self) -> Result<Repository>
Sourcepub fn new_password_file(
&mut self,
path_end: &str,
content: &str,
) -> Result<PasswordEntry>
pub fn new_password_file( &mut self, path_end: &str, content: &str, ) -> Result<PasswordEntry>
Creates a new password file in the store.
§Errors
Returns an Err if the path points to a file outside the password store or the file already exists.
Sourcepub fn reload_password_list(&mut self) -> Result<()>
pub fn reload_password_list(&mut self) -> Result<()>
loads the list of passwords from disk again
§Errors
Returns an error if any of the passwords contain non-utf8 bytes
Sourcepub fn has_configured_username(&self) -> bool
pub fn has_configured_username(&self) -> bool
checks if there is a username configured in git
Sourcepub fn all_passwords(&self) -> Result<Vec<PasswordEntry>>
pub fn all_passwords(&self) -> Result<Vec<PasswordEntry>>
Read the password store directory and return a list of all the password files.
§Errors
Returns an error if any of the passwords contain non-utf8 bytes
Sourcepub fn all_recipients(&self) -> Result<Vec<Recipient>>
pub fn all_recipients(&self) -> Result<Vec<Recipient>>
Return a list of all the Recipients in the $PASSWORD_STORE_DIR/.gpg-id file.
§Errors
Returns an Err if the gpg_id file should be verified and it can’t be
Sourcepub fn recipients_for_path(&self, path: &Path) -> Result<Vec<Recipient>>
pub fn recipients_for_path(&self, path: &Path) -> Result<Vec<Recipient>>
Return a list of all the Recipients in the .gpg-id file that is the
closest parent to path.
§Errors
Returns an Err if the gpg_id file should be verified and it can’t be
Sourcepub fn remove_recipient(&self, r: &Recipient, path: &Path) -> Result<()>
pub fn remove_recipient(&self, r: &Recipient, path: &Path) -> Result<()>
Removes a key from the .gpg-id file and re-encrypts all the passwords
§Errors
Returns an Err if the gpg_id file can’t be verified when it should
or if the recipient is the last one.
Sourcepub fn add_recipient(
&mut self,
r: &Recipient,
path: &Path,
config_path: &Path,
) -> Result<()>
pub fn add_recipient( &mut self, r: &Recipient, path: &Path, config_path: &Path, ) -> Result<()>
Adds a key to the .gpg-id file in the path directory and re-encrypts all the passwords
§Errors
Returns an Err if the gpg_id file can’t be verified when it should or there is some problem with
the encryption.
Sourcepub fn add_and_commit(&self, paths: &[PathBuf], message: &str) -> Result<Oid>
pub fn add_and_commit(&self, paths: &[PathBuf], message: &str) -> Result<Oid>
Add a file to the store, and commit it to the supplied git repository.
§Errors
Returns an Err if there is any problems with git.