Skip to content

Commit

Permalink
Rename type.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpfs committed Nov 27, 2023
1 parent 2df2395 commit de2cb26
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 40 deletions.
20 changes: 10 additions & 10 deletions tests/integration/external_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{path::PathBuf, sync::Arc};
use sos_net::{
client::UserStorage,
sdk::{
account::{files::FileProgress, SecretOptions},
account::{files::FileProgress, AccessOptions},
hex,
vault::{
secret::{
Expand Down Expand Up @@ -195,7 +195,7 @@ async fn create_file_secret(
let (meta, secret, file_path) = get_image_secret()?;

// Create the file secret in the default folder
let options = SecretOptions {
let options = AccessOptions {
folder: Some(default_folder.clone()),
file_progress: Some(progress_tx),
};
Expand Down Expand Up @@ -223,7 +223,7 @@ async fn update_file_secret(
id,
new_meta,
"tests/fixtures/test-file.txt",
SecretOptions {
AccessOptions {
folder: None,
file_progress: Some(progress_tx),
},
Expand Down Expand Up @@ -351,7 +351,7 @@ async fn assert_move_file_secret(
id,
default_folder,
&destination,
SecretOptions {
AccessOptions {
folder: None,
file_progress: Some(progress_tx),
},
Expand Down Expand Up @@ -405,7 +405,7 @@ async fn assert_delete_file_secret(
checksum: &[u8; 32],
progress_tx: mpsc::Sender<FileProgress>,
) -> Result<()> {
let options = SecretOptions {
let options = AccessOptions {
folder: Some(folder.clone()),
file_progress: Some(progress_tx),
};
Expand Down Expand Up @@ -520,7 +520,7 @@ async fn assert_attach_file_secret(
&id,
secret_data.meta,
Some(secret_data.secret),
SecretOptions {
AccessOptions {
folder: Some(folder.clone()),
file_progress: Some(progress_tx.clone()),
},
Expand Down Expand Up @@ -615,7 +615,7 @@ async fn assert_attach_file_secret(
&id,
secret_data.meta.clone(),
Some(secret_data.secret.clone()),
SecretOptions {
AccessOptions {
folder: Some(folder.clone()),
file_progress: Some(progress_tx.clone()),
},
Expand Down Expand Up @@ -677,7 +677,7 @@ async fn assert_attach_file_secret(
&id,
updated_secret_data.meta,
Some(updated_secret_data.secret),
SecretOptions {
AccessOptions {
folder: Some(folder.clone()),
file_progress: Some(progress_tx.clone()),
},
Expand Down Expand Up @@ -738,7 +738,7 @@ async fn assert_attach_file_secret(
&id,
insert_attachment_secret_data.meta,
Some(insert_attachment_secret_data.secret),
SecretOptions {
AccessOptions {
folder: Some(folder.clone()),
file_progress: Some(progress_tx.clone()),
},
Expand Down Expand Up @@ -780,7 +780,7 @@ async fn assert_attach_file_secret(
owner
.delete_secret(
&id,
SecretOptions {
AccessOptions {
folder: Some(folder.clone()),
file_progress: Some(progress_tx.clone()),
},
Expand Down
20 changes: 10 additions & 10 deletions workspace/net/src/client/account/user_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use sos_sdk::{
search::{AccountSearch, DocumentCount, SearchIndex, AccountStatistics},
Account, AccountBuilder, AccountData, AccountHandler, AccountInfo,
AuthenticatedUser, DelegatedPassphrase, DetachedView,
AccountsList, LocalProvider, NewAccount, SecretOptions, UserPaths,
AccountsList, LocalProvider, NewAccount, AccessOptions, UserPaths,
},
commit::{CommitHash, CommitProof, CommitState},
crypto::{AccessKey, SecureAccessKey},
Expand Down Expand Up @@ -526,7 +526,7 @@ impl UserStorage {
let audit_event: AuditEvent = (self.address(), &event).into();
self.append_audit_logs(vec![audit_event]).await?;
let options = SecretOptions {
let options = AccessOptions {
folder: Some(summary),
..Default::default()
};
Expand Down Expand Up @@ -650,7 +650,7 @@ impl UserStorage {
/// hash and the proof for the current head of the events log.
async fn before_apply_events(
&self,
options: &SecretOptions,
options: &AccessOptions,
apply_changes: bool,
) -> Result<(Summary, Option<CommitHash>, CommitProof)> {
let (folder, mut last_commit, mut commit_proof) = {
Expand Down Expand Up @@ -710,7 +710,7 @@ impl UserStorage {
&mut self,
meta: SecretMeta,
secret: Secret,
options: SecretOptions,
options: AccessOptions,
) -> Result<(SecretId, Option<SyncError>)> {
let _ = self.sync_lock.lock().await;

Expand Down Expand Up @@ -744,7 +744,7 @@ impl UserStorage {
secret_id: &SecretId,
meta: SecretMeta,
path: P,
options: SecretOptions,
options: AccessOptions,
destination: Option<&Summary>,
) -> Result<(SecretId, Option<SyncError>)> {
let _ = self.sync_lock.lock().await;
Expand All @@ -768,7 +768,7 @@ impl UserStorage {
secret_id: &SecretId,
meta: SecretMeta,
secret: Option<Secret>,
mut options: SecretOptions,
mut options: AccessOptions,
destination: Option<&Summary>,
) -> Result<(SecretId, Option<SyncError>)> {
let _ = self.sync_lock.lock().await;
Expand All @@ -792,7 +792,7 @@ impl UserStorage {
secret_id: &SecretId,
from: &Summary,
to: &Summary,
options: SecretOptions,
options: AccessOptions,
) -> Result<(SecretId, Event)> {
let _ = self.sync_lock.lock().await;
Ok(self
Expand All @@ -805,7 +805,7 @@ impl UserStorage {
pub async fn delete_secret(
&mut self,
secret_id: &SecretId,
mut options: SecretOptions,
mut options: AccessOptions,
) -> Result<Option<SyncError>> {
let _ = self.sync_lock.lock().await;

Expand All @@ -827,7 +827,7 @@ impl UserStorage {
&mut self,
from: &Summary,
secret_id: &SecretId,
options: SecretOptions,
options: AccessOptions,
) -> Result<(SecretId, Event)> {
let _ = self.sync_lock.lock().await;

Expand All @@ -842,7 +842,7 @@ impl UserStorage {
from: &Summary,
secret_id: &SecretId,
secret_meta: &SecretMeta,
options: SecretOptions,
options: AccessOptions,
) -> Result<(Summary, SecretId, Event)> {
let _ = self.sync_lock.lock().await;
Ok(self
Expand Down
37 changes: 18 additions & 19 deletions workspace/sdk/src/account/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ impl DetachedView {
}
}

/// Options used when creating, deleting and updating
/// secrets.
/// Options used when accessing account data.
#[derive(Default)]
pub struct SecretOptions {
/// Target folder for the secret operation.
pub struct AccessOptions {
/// Target folder for the operation.
///
/// If no target folder is given the current open folder
/// will be used. When no folder is open and the target
Expand All @@ -99,7 +98,7 @@ pub struct SecretOptions {
pub file_progress: Option<mpsc::Sender<FileProgress>>,
}

impl From<Summary> for SecretOptions {
impl From<Summary> for AccessOptions {
fn from(value: Summary) -> Self {
Self {
folder: Some(value),
Expand Down Expand Up @@ -582,7 +581,7 @@ impl<D> Account<D> {
let audit_event: AuditEvent = (self.address(), &event).into();
self.append_audit_logs(vec![audit_event]).await?;

let options = SecretOptions {
let options = AccessOptions {
folder: Some(summary),
..Default::default()
};
Expand All @@ -601,7 +600,7 @@ impl<D> Account<D> {
&mut self,
summary: &Summary,
) -> Result<(Event, CommitState)> {
let options = SecretOptions {
let options = AccessOptions {
folder: Some(summary.clone()),
..Default::default()
};
Expand Down Expand Up @@ -636,7 +635,7 @@ impl<D> Account<D> {
summary: &Summary,
name: String,
) -> Result<(Event, CommitState)> {
let options = SecretOptions {
let options = AccessOptions {
folder: Some(summary.clone()),
..Default::default()
};
Expand Down Expand Up @@ -857,7 +856,7 @@ impl<D> Account<D> {
let audit_event: AuditEvent = (self.address(), &event).into();
self.append_audit_logs(vec![audit_event]).await?;

let options = SecretOptions {
let options = AccessOptions {
folder: Some(summary.clone()),
..Default::default()
};
Expand Down Expand Up @@ -922,7 +921,7 @@ impl<D> Account<D> {
/// hash and the proof for the current head of the events log.
async fn compute_folder_state(
&self,
options: &SecretOptions,
options: &AccessOptions,
apply_changes: bool,
) -> Result<(Summary, CommitState)> {
let (folder, last_commit, mut commit_proof) = {
Expand Down Expand Up @@ -970,7 +969,7 @@ impl<D> Account<D> {
&mut self,
meta: SecretMeta,
secret: Secret,
options: SecretOptions,
options: AccessOptions,
) -> Result<(SecretId, Event, CommitState, Summary)> {
let (folder, commit_state) =
self.compute_folder_state(&options, true).await?;
Expand All @@ -985,7 +984,7 @@ impl<D> Account<D> {
&mut self,
meta: SecretMeta,
secret: Secret,
mut options: SecretOptions,
mut options: AccessOptions,
audit: bool,
) -> Result<(SecretId, Event, Summary)> {
let folder = {
Expand Down Expand Up @@ -1111,7 +1110,7 @@ impl<D> Account<D> {
secret_id: &SecretId,
meta: SecretMeta,
path: P,
options: SecretOptions,
options: AccessOptions,
destination: Option<&Summary>,
) -> Result<(SecretId, Event, CommitState, Summary)> {
let path = path.as_ref().to_path_buf();
Expand All @@ -1132,7 +1131,7 @@ impl<D> Account<D> {
secret_id: &SecretId,
meta: SecretMeta,
secret: Option<Secret>,
mut options: SecretOptions,
mut options: AccessOptions,
destination: Option<&Summary>,
) -> Result<(SecretId, Event, CommitState, Summary)> {
let (folder, commit_state) =
Expand Down Expand Up @@ -1229,7 +1228,7 @@ impl<D> Account<D> {
secret_id: &SecretId,
from: &Summary,
to: &Summary,
options: SecretOptions,
options: AccessOptions,
) -> Result<(SecretId, Event)> {
self.mv_secret(secret_id, from, to, options).await
}
Expand All @@ -1239,7 +1238,7 @@ impl<D> Account<D> {
secret_id: &SecretId,
from: &Summary,
to: &Summary,
mut options: SecretOptions,
mut options: AccessOptions,
) -> Result<(SecretId, Event)> {
self.open_vault(from, false).await?;
let (secret_data, read_event) =
Expand Down Expand Up @@ -1297,7 +1296,7 @@ impl<D> Account<D> {
pub async fn delete_secret(
&mut self,
secret_id: &SecretId,
mut options: SecretOptions,
mut options: AccessOptions,
) -> Result<(Event, CommitState, Summary)> {
let (folder, commit_state) =
self.compute_folder_state(&options, true).await?;
Expand Down Expand Up @@ -1359,7 +1358,7 @@ impl<D> Account<D> {
&mut self,
from: &Summary,
secret_id: &SecretId,
options: SecretOptions,
options: AccessOptions,
) -> Result<(SecretId, Event)> {
if from.flags().is_archive() {
return Err(Error::AlreadyArchived);
Expand All @@ -1380,7 +1379,7 @@ impl<D> Account<D> {
from: &Summary,
secret_id: &SecretId,
secret_meta: &SecretMeta,
options: SecretOptions,
options: AccessOptions,
) -> Result<(Summary, SecretId, Event)> {
if !from.flags().is_archive() {
return Err(Error::NotArchived);
Expand Down
2 changes: 1 addition & 1 deletion workspace/sdk/src/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub mod search;
pub mod security_report;

pub use account::{
Account, AccountData, AccountHandler, DetachedView, SecretOptions,
Account, AccountData, AccountHandler, DetachedView, AccessOptions,
};
pub use builder::{AccountBuilder, NewAccount};
pub use identity::{AccountStatus, Identity};
Expand Down

0 comments on commit de2cb26

Please sign in to comment.