Skip to main content

Store

Struct Store 

Source
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

Source

pub fn open(config: Config, identity: Identity) -> Result<Self>

Opens an existing store and validates its recipients.

§Errors
Source

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
Source

pub fn root(&self) -> &Path

Returns the absolute store directory.

Source

pub const fn identity(&self) -> &Identity

Returns the unlocked identity.

Source

pub fn recipients(&self) -> &[Recipient]

Returns the configured recipient list.

Source

pub fn exists(&self, logical: &str) -> bool

Returns true if a secret exists at logical.

Source

pub fn get(&self, logical: &str) -> Result<Secret>

Reads and decrypts the secret at logical.

§Errors
Source

pub fn set(&self, logical: &str, secret: &Secret) -> Result<()>

Encrypts and writes (or overwrites) secret at logical.

§Errors
Source

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.

Source

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.

Source

pub fn rename(&self, from: &str, to: &str) -> Result<()>

Renames a secret from one logical path to another.

§Errors
Source

pub fn list(&self, prefix: &str) -> Result<Vec<String>>

Lists logical paths under prefix (use "" for all), sorted.

§Errors

Returns Error::Io on directory traversal failures.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Store

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl UnwindSafe for Store

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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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<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