[][src]Struct libknox::VaultContext

pub struct VaultContext {
    pub path: String,
    pub vault: Vault,
}

Handle around a Vault instance.

Fields

path: Stringvault: Vault

Methods

impl VaultContext[src]

pub fn create<P>(path: P, identities: &[String]) -> Result<Self, Box<dyn Error>> where
    P: AsRef<Path>, 
[src]

Create a new vault.

Initializes a new empty vault, encrypted with the provided GPG identities. This function will fail if the given path is not empty or if a public key matching the identity cannot be found.

Arguments

  • path - the filesystem path at which to create the vault.
  • identities - a slice if GPG identities, represented by their owner's email address.

pub fn open<P>(path: P) -> Result<Self, Box<dyn Error>> where
    P: AsRef<Path>, 
[src]

Return a handle to a Vault from the filesystem.

Opens, decrypt the metadata of, and returns a handle that allows you to manipulate a Vault. This function will fail of the given path is not a vault instance or if it cannot be decrypted with an available GPG private key.

Arguments

  • path - filesystem path where the vault is located.

pub fn write(&self) -> Result<(), Box<dyn Error>>[src]

Write the vault metadata.

Persists all changes to the vault's metadata into the _knox.meta file containing the encrypted mapping between virtual (user) secret paths and filesystem paths.

This requires the GPG public keys of all identities used in the vault.

pub fn add_index(&mut self, path: &str, destination: &str)[src]

Add an Entry to the index.

Adds an Entry to the index of a vault, allowing to retrieve a filesystem path from a virtual path. This does not manage the secret itself.

To persist the change, refer to VaultContext::write.

Arguments

  • path - virtual path to the entry.
  • destination - physical filesystem path to the entry.

pub fn remove_index(&mut self, path: &str)[src]

Remove an Entry from the index.

Removes an Entry to the index of a vault, allowing to retrieve a filesystem path from a virtual path. This does not manage the secret itself.

To persist the change, refer to VaultContext::write.

Arguments

  • path - virtual path to the entry

pub fn read_entry(&self, path: &str) -> Result<Entry, Box<dyn Error>>[src]

Read an Entry.

Takes a virtual path and returns the decrypted Entry from the vault, if it exists.

Arguments

  • path - the virtual path to the entry.

pub fn write_entry(
    &mut self,
    path: &str,
    entry: &Entry
) -> Result<(), Box<dyn Error>>
[src]

Persist an Entry.

Encrypts and writes an Entry to its physical location as described in the vault's index. The entry must exist in the index beforehand.

This requires the GPG public keys of all identities used in the vault.

Arguments

  • path - the virtual path to the entry.
  • entry - the Entry to be written.

pub fn delete_entry(&mut self, path: &str) -> Result<(), Box<dyn Error>>[src]

Delete an Entry.

Deletes an Entry both from its backing filesystem location and from the index.

This requires the GPG public keys of all identities used in the vault because the index needs to be updated.

Arguments

  • path - the virtual path to the entry.

pub fn has_pack<P>(&self, path: P) -> bool where
    P: AsRef<Path>, 
[src]

Check if a file exists under the vault's directory.

Arguments

    • path - a path relative to the vault's root directory.

pub fn add_identity(&mut self, identity: &str)[src]

Add an identity to the vault

Saves a new identity to the vault's metadata. This does not touch any existing secrets, which should be re-encrypted for the new identity to be used.

Arguments

  • identity - the GPG identity

pub fn remove_identity(&mut self, identity: &str)[src]

Remove an identity from the vault.

Removes an existing identity from the vault's metadata. This does not touch any existing secrets, which should be re-encrypted for the removed identity to be unable de decrypt them.

Arguments

  • identity - the GPG identity

pub fn git_init(&self) -> Result<(), Box<dyn Error>>[src]

Initialize a local git repository

pub fn commit(&self, message: &str) -> Result<(), Box<dyn Error>>[src]

Commit all unstaged files to git repository

Use this function to add all uncommitted modifications to the git index and commit them into the local git repository.

Arguments

  • message - the commit message to be used for the commit

pub fn set_git_origin(&self, origin: &str) -> Result<(), Box<dyn Error>>[src]

Set the URL of the remote git repository

No particular check is performed on the validity of the provided URL.

Arguments

  • origin - the URL for the remote git repository

pub fn push(&self) -> Result<(), Box<dyn Error>>[src]

Push all commited data to the remote git repository

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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

type Err = NoError

The error type produced by a failed conversion.

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

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

The error type produced by a failed conversion.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> ConvUtil for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<Src> TryFrom<Src> for Src

type Err = NoError

The error type produced by a failed conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The error type produced by a failed conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

impl<Src> ValueFrom<Src> for Src

type Err = NoError

The error type produced by a failed conversion.

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

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

The error type produced by a failed conversion.