[−][src]Struct libknox::VaultContext
Handle around a Vault instance.
Fields
path: String
vault: Vault
Methods
impl VaultContext
[src]
pub fn create<P>(path: P, identities: &[String]) -> Result<Self, Box<dyn Error>> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
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]
P: AsRef<Path>,
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]
&mut self,
path: &str,
entry: &Entry
) -> Result<(), Box<dyn Error>>
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
- theEntry
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]
P: AsRef<Path>,
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
impl RefUnwindSafe for VaultContext
impl Send for VaultContext
impl Sync for VaultContext
impl Unpin for VaultContext
impl UnwindSafe for VaultContext
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
Scheme: ApproxScheme,
Scheme: ApproxScheme,
type Err = NoError
The error type produced by a failed conversion.
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src where
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, Dst> ConvAsUtil<Dst> for T
fn approx(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, DefaultApprox>,
Self: ApproxInto<Dst, DefaultApprox>,
fn approx_by<Scheme>(self) -> Result<Dst, Self::Err> where
Scheme: ApproxScheme,
Self: ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Self: ApproxInto<Dst, Scheme>,
impl<T> ConvUtil for T
fn approx_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, DefaultApprox>,
Self: ApproxInto<Dst, DefaultApprox>,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err> where
Scheme: ApproxScheme,
Self: ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Self: ApproxInto<Dst, Scheme>,
fn into_as<Dst>(self) -> Dst where
Self: Into<Dst>,
Self: Into<Dst>,
fn try_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: TryInto<Dst>,
Self: TryInto<Dst>,
fn value_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: ValueInto<Dst>,
Self: ValueInto<Dst>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<Src, Dst> TryInto<Dst> for Src where
Dst: TryFrom<Src>,
Dst: TryFrom<Src>,
type Err = <Dst as TryFrom<Src>>::Err
The error type produced by a failed conversion.
fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<Src> ValueFrom<Src> for Src
type Err = NoError
The error type produced by a failed conversion.
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
impl<Src, Dst> ValueInto<Dst> for Src where
Dst: ValueFrom<Src>,
Dst: ValueFrom<Src>,
type Err = <Dst as ValueFrom<Src>>::Err
The error type produced by a failed conversion.