PasswordStore

Struct PasswordStore 

Source
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

Source

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

Source

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.

Source

pub fn get_name(&self) -> &String

Returns the name of the store, configured to the configuration file

Source

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

Source

pub fn get_store_path(&self) -> PathBuf

returns the path to the directory where the store is located.

Source

pub fn get_user_home(&self) -> Option<PathBuf>

Source

pub fn get_style_file(&self) -> Option<PathBuf>

returns the style file for the store

Source

pub fn get_crypto(&self) -> &(dyn Crypto + Send)

returns the crypto implementation for the store

Source

pub fn repo(&self) -> Result<Repository>

Source

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.

Source

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

Source

pub fn has_configured_username(&self) -> bool

checks if there is a username configured in git

Source

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

Source

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

Source

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

Source

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.

Source

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.

Source

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.

Source

pub fn rename_file(&mut self, old_name: &str, new_name: &str) -> Result<usize>

Renames a password file to a new name returns the index in the password vec of the renamed PasswordEntry

§Errors

Returns an Err if the file is missing, or the target already exists.

Source

pub fn recipient_from( &self, key_id: &str, pre_comment: &[String], post_comment: Option<String>, ) -> Result<Recipient>

Creates a Recipient their key_id.

§Errors

Returns an Err if there is anything wrong with the Recipient

Trait Implementations§

Source§

impl Default for PasswordStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src
where Scheme: ApproxScheme,

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>

Convert the given value into an approximately equivalent representation.
Source§

impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src
where Dst: ApproxFrom<Src, Scheme>, Scheme: ApproxScheme,

Source§

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.
Source§

fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>

Convert the subject into an approximately equivalent representation.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, Dst> ConvAsUtil<Dst> for T

Source§

fn approx(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject with the default scheme.
Source§

fn approx_by<Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject with a specific scheme.
Source§

impl<T> ConvUtil for T

Source§

fn approx_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject to a given type with the default scheme.
Source§

fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject to a given type with a specific scheme.
Source§

fn into_as<Dst>(self) -> Dst
where Self: Sized + Into<Dst>,

Convert the subject to a given type.
Source§

fn try_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + TryInto<Dst>,

Attempt to convert the subject to a given type.
Source§

fn value_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ValueInto<Dst>,

Attempt a value conversion of the subject to a given type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Src> TryFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>

Convert the given value into the subject type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<Src, Dst> TryInto<Dst> for Src
where Dst: TryFrom<Src>,

Source§

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>

Convert the subject into the destination type.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<Src> ValueFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>

Convert the given value into an exactly equivalent representation.
Source§

impl<Src, Dst> ValueInto<Dst> for Src
where Dst: ValueFrom<Src>,

Source§

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>

Convert the subject into an exactly equivalent representation.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more