Folder

Struct Folder 

Source
pub struct Folder { /* private fields */ }
Expand description

Folder is a combined vault and event log.

Implementations§

Source§

impl Folder

Source

pub async fn new( target: BackendTarget, account_id: &AccountId, folder_id: &VaultId, ) -> Result<Self, Error>

Create a new folder.

Changes to the in-memory vault are mirrored to storage.

Source

pub async fn from_vault_event_log( target: &BackendTarget, vault: Vault, event_log: FolderEventLog, ) -> Result<Self, Error>

Create a new folder using a vault and events.

Source

pub async fn from_path( path: impl AsRef<Path>, account_id: &AccountId, log_type: EventLogType, ) -> Result<Self, Error>

Create a new folder from a vault on disc.

Changes to the in-memory vault are mirrored to disc and and if an event log does not exist it is created.

If an event log exists the commit tree is loaded into memory.

Source

pub async fn id(&self) -> VaultId

Folder identifier.

Source

pub fn access_point(&self) -> Arc<Mutex<AccessPoint>>

Access point for this folder.

Source

pub fn event_log(&self) -> Arc<RwLock<FolderEventLog>>

Clone of the event log.

Source

pub async fn unlock(&mut self, key: &AccessKey) -> Result<VaultMeta, Error>

Unlock using the folder access key.

Source

pub async fn lock(&mut self)

Lock the folder.

Source

pub async fn create_secret( &mut self, secret_data: &SecretRow, ) -> Result<WriteEvent, Error>

Create a secret.

Source

pub async fn read_secret( &self, id: &SecretId, ) -> Result<Option<(SecretMeta, Secret, ReadEvent)>, Error>

Get a secret and it’s meta data.

Source

pub async fn raw_secret( &self, id: &SecretId, ) -> Result<Option<(VaultCommit, ReadEvent)>, Error>

Read the encrypted contents of a secret.

Source

pub async fn update_secret( &mut self, id: &SecretId, secret_meta: SecretMeta, secret: Secret, ) -> Result<Option<WriteEvent>, Error>

Update a secret.

Source

pub async fn delete_secret( &mut self, id: &SecretId, ) -> Result<Option<WriteEvent>, Error>

Delete a secret and it’s meta data.

Source

pub async fn rename_folder( &mut self, name: impl AsRef<str>, ) -> Result<WriteEvent, Error>

Set the name of the folder.

Source

pub async fn update_folder_flags( &mut self, flags: VaultFlags, ) -> Result<WriteEvent, Error>

Set the folder flags.

Source

pub async fn description(&self) -> Result<String, Error>

Description of this folder.

Source

pub async fn set_description( &mut self, description: impl AsRef<str>, ) -> Result<WriteEvent, Error>

Set the description of this folder.

Source

pub async fn set_meta(&mut self, meta: &VaultMeta) -> Result<WriteEvent, Error>

Set the folder meta data.

Source

pub async fn commit_state(&self) -> Result<CommitState, Error>

Folder commit state.

Source

pub async fn root_hash(&self) -> Result<CommitHash, Error>

Folder root commit hash.

Source

pub async fn apply(&mut self, events: &[WriteEvent]) -> Result<(), Error>

Apply events to the event log.

Source

pub async fn apply_records( &mut self, records: Vec<EventRecord>, ) -> Result<(), Error>

Apply event records to the event log.

Source

pub async fn clear(&mut self) -> Result<(), Error>

Clear events from the event log.

Trait Implementations§

Source§

impl Clone for Folder

Source§

fn clone(&self) -> Folder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl From<Folder> for Vault

Source§

fn from(value: Folder) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Folder

§

impl !RefUnwindSafe for Folder

§

impl Send for Folder

§

impl Sync for Folder

§

impl Unpin for Folder

§

impl !UnwindSafe for Folder

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,