pub struct Folder { /* private fields */ }Expand description
Folder is a combined vault and event log.
Implementations§
Source§impl Folder
impl Folder
Sourcepub async fn new(
target: BackendTarget,
account_id: &AccountId,
folder_id: &VaultId,
) -> Result<Self, Error>
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.
Sourcepub async fn from_vault_event_log(
target: &BackendTarget,
vault: Vault,
event_log: FolderEventLog,
) -> Result<Self, Error>
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.
Sourcepub async fn from_path(
path: impl AsRef<Path>,
account_id: &AccountId,
log_type: EventLogType,
) -> Result<Self, Error>
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.
Sourcepub fn access_point(&self) -> Arc<Mutex<AccessPoint>>
pub fn access_point(&self) -> Arc<Mutex<AccessPoint>>
Access point for this folder.
Sourcepub fn event_log(&self) -> Arc<RwLock<FolderEventLog>>
pub fn event_log(&self) -> Arc<RwLock<FolderEventLog>>
Clone of the event log.
Sourcepub async fn unlock(&mut self, key: &AccessKey) -> Result<VaultMeta, Error>
pub async fn unlock(&mut self, key: &AccessKey) -> Result<VaultMeta, Error>
Unlock using the folder access key.
Sourcepub async fn create_secret(
&mut self,
secret_data: &SecretRow,
) -> Result<WriteEvent, Error>
pub async fn create_secret( &mut self, secret_data: &SecretRow, ) -> Result<WriteEvent, Error>
Create a secret.
Sourcepub async fn read_secret(
&self,
id: &SecretId,
) -> Result<Option<(SecretMeta, Secret, ReadEvent)>, Error>
pub async fn read_secret( &self, id: &SecretId, ) -> Result<Option<(SecretMeta, Secret, ReadEvent)>, Error>
Get a secret and it’s meta data.
Sourcepub async fn raw_secret(
&self,
id: &SecretId,
) -> Result<Option<(VaultCommit, ReadEvent)>, Error>
pub async fn raw_secret( &self, id: &SecretId, ) -> Result<Option<(VaultCommit, ReadEvent)>, Error>
Read the encrypted contents of a secret.
Sourcepub async fn update_secret(
&mut self,
id: &SecretId,
secret_meta: SecretMeta,
secret: Secret,
) -> Result<Option<WriteEvent>, Error>
pub async fn update_secret( &mut self, id: &SecretId, secret_meta: SecretMeta, secret: Secret, ) -> Result<Option<WriteEvent>, Error>
Update a secret.
Sourcepub async fn delete_secret(
&mut self,
id: &SecretId,
) -> Result<Option<WriteEvent>, Error>
pub async fn delete_secret( &mut self, id: &SecretId, ) -> Result<Option<WriteEvent>, Error>
Delete a secret and it’s meta data.
Sourcepub async fn rename_folder(
&mut self,
name: impl AsRef<str>,
) -> Result<WriteEvent, Error>
pub async fn rename_folder( &mut self, name: impl AsRef<str>, ) -> Result<WriteEvent, Error>
Set the name of the folder.
Sourcepub async fn update_folder_flags(
&mut self,
flags: VaultFlags,
) -> Result<WriteEvent, Error>
pub async fn update_folder_flags( &mut self, flags: VaultFlags, ) -> Result<WriteEvent, Error>
Set the folder flags.
Sourcepub async fn description(&self) -> Result<String, Error>
pub async fn description(&self) -> Result<String, Error>
Description of this folder.
Sourcepub async fn set_description(
&mut self,
description: impl AsRef<str>,
) -> Result<WriteEvent, Error>
pub async fn set_description( &mut self, description: impl AsRef<str>, ) -> Result<WriteEvent, Error>
Set the description of this folder.
Sourcepub async fn set_meta(&mut self, meta: &VaultMeta) -> Result<WriteEvent, Error>
pub async fn set_meta(&mut self, meta: &VaultMeta) -> Result<WriteEvent, Error>
Set the folder meta data.
Sourcepub async fn commit_state(&self) -> Result<CommitState, Error>
pub async fn commit_state(&self) -> Result<CommitState, Error>
Folder commit state.
Sourcepub async fn root_hash(&self) -> Result<CommitHash, Error>
pub async fn root_hash(&self) -> Result<CommitHash, Error>
Folder root commit hash.
Sourcepub async fn apply(&mut self, events: &[WriteEvent]) -> Result<(), Error>
pub async fn apply(&mut self, events: &[WriteEvent]) -> Result<(), Error>
Apply events to the event log.
Sourcepub async fn apply_records(
&mut self,
records: Vec<EventRecord>,
) -> Result<(), Error>
pub async fn apply_records( &mut self, records: Vec<EventRecord>, ) -> Result<(), Error>
Apply event records to the event log.