pub struct Store { /* private fields */ }Expand description
The encrypted store, bound to a config, a recipient list and an unlocked identity.
Implementations§
Source§impl Store
impl Store
Sourcepub fn open(config: Config, identity: Identity) -> Result<Self>
pub fn open(config: Config, identity: Identity) -> Result<Self>
Opens an existing store and validates its recipients.
§Errors
Error::StoreNotFoundifstore_dirdoes not exist.Error::NoRecipientsif.recipientsis missing or empty.Error::Io/Error::InvalidRecipienton parse failures.
Sourcepub fn create(
config: Config,
identity: Identity,
extra_recipients: &[Recipient],
) -> Result<Self>
pub fn create( config: Config, identity: Identity, extra_recipients: &[Recipient], ) -> Result<Self>
Creates a brand-new store: store_dir/, .recipients, and an empty tree.
identity is the just-created user identity. Its public key plus any
extra_recipients are written into .recipients.
§Errors
Error::StoreExistsif.recipientsalready exists instore_dir.Error::Ioon filesystem failures.
Sourcepub fn recipients(&self) -> &[Recipient]
pub fn recipients(&self) -> &[Recipient]
Returns the configured recipient list.
Sourcepub fn get(&self, logical: &str) -> Result<Secret>
pub fn get(&self, logical: &str) -> Result<Secret>
Reads and decrypts the secret at logical.
§Errors
Error::InvalidPathfor malformed paths.Error::SecretNotFoundif no such file exists.Error::Decrypt/Error::Ioon failure.
Sourcepub fn set(&self, logical: &str, secret: &Secret) -> Result<()>
pub fn set(&self, logical: &str, secret: &Secret) -> Result<()>
Encrypts and writes (or overwrites) secret at logical.
§Errors
Error::InvalidPathfor malformed paths.Error::Io/Error::Encrypton failure.
Sourcepub fn insert(&self, logical: &str, secret: &Secret) -> Result<()>
pub fn insert(&self, logical: &str, secret: &Secret) -> Result<()>
Inserts a new secret, failing if one already exists.
§Errors
Returns Error::SecretExists if a file is already present.
Sourcepub fn delete(&self, logical: &str) -> Result<()>
pub fn delete(&self, logical: &str) -> Result<()>
Deletes the secret at logical. Also prunes now-empty parent
directories up to (but not including) the store root.
§Errors
Returns Error::SecretNotFound if the file is absent.
Sourcepub fn rename(&self, from: &str, to: &str) -> Result<()>
pub fn rename(&self, from: &str, to: &str) -> Result<()>
Renames a secret from one logical path to another.
§Errors
Error::SecretNotFoundiffromdoes not exist.Error::SecretExistsiftoalready exists.Error::InvalidPathfor malformedto.
Sourcepub fn find(&self, query: &str, include_notes: bool) -> Result<Vec<String>>
pub fn find(&self, query: &str, include_notes: bool) -> Result<Vec<String>>
Searches paths and decrypted notes case-insensitively for query.
Notes are scanned only when include_notes is true (which requires
decrypting every secret — slow on large stores).
§Errors
Returns Error::Io / Error::Decrypt on failure when scanning notes.
Sourcepub fn set_recipients(
&mut self,
new_recipients: Vec<Recipient>,
) -> Result<usize>
pub fn set_recipients( &mut self, new_recipients: Vec<Recipient>, ) -> Result<usize>
Replaces the recipient list and re-encrypts every secret.
new_recipients must contain at least the current user’s public key
(otherwise we’d lock ourselves out — checked).
§Errors
Returns Error::InvalidRecipient if the resulting list does not
include the user’s own public key, or Error::Io / Error::Decrypt
during re-encryption.