pub struct Paths { /* private fields */ }Expand description
File system paths.
Clients and servers may be configured to run on the same machine and point to the same data directory so different prefixes are used to distinguish.
Clients write to a local directory whilst servers write to a
remote directory.
Several functions require a user identifier and will panic if a user identifier has not been set, see the function documentation for details.
Implementations§
Source§impl Paths
impl Paths
Sourcepub fn new_client(documents_dir: impl AsRef<Path>) -> Arc<Self>
pub fn new_client(documents_dir: impl AsRef<Path>) -> Arc<Self>
Create paths for a client without an account identifier.
Sourcepub fn new_server(documents_dir: impl AsRef<Path>) -> Arc<Self>
pub fn new_server(documents_dir: impl AsRef<Path>) -> Arc<Self>
Create paths for a server without an account identifier.
Sourcepub fn with_account_id(&self, account_id: &AccountId) -> Arc<Self>
pub fn with_account_id(&self, account_id: &AccountId) -> Arc<Self>
Clone of paths with an account identifier.
Sourcepub async fn ensure(&self) -> Result<(), Error>
pub async fn ensure(&self) -> Result<(), Error>
Ensure the local storage directory exists.
If a user identifier is available this will also create some user-specific directories.
Sourcepub fn is_using_db(&self) -> bool
pub fn is_using_db(&self) -> bool
Determine if a database file exists.
Sourcepub async fn is_usable(&self) -> Result<bool, Error>
pub async fn is_usable(&self) -> Result<bool, Error>
Try to determine if the account is ready to be used by checking for the presence of required files on disc.
Sourcepub fn into_files_dir(&self) -> PathBuf
pub fn into_files_dir(&self) -> PathBuf
Expected directory for external file blobs for an account.
§Panics
If this set of paths are global (no user identifier).
Sourcepub fn into_file_folder_path(&self, folder_id: &VaultId) -> PathBuf
pub fn into_file_folder_path(&self, folder_id: &VaultId) -> PathBuf
Expected location for the directory containing all the external files for a folder.
§Panics
If this set of paths are global (no user identifier).
Sourcepub fn into_file_secret_path(
&self,
folder_id: &VaultId,
secret_id: &SecretId,
) -> PathBuf
pub fn into_file_secret_path( &self, folder_id: &VaultId, secret_id: &SecretId, ) -> PathBuf
Expected location for the directory containing all the external files for a secret.
§Panics
If this set of paths are global (no user identifier).
Sourcepub fn into_file_path(&self, file: &ExternalFile) -> PathBuf
pub fn into_file_path(&self, file: &ExternalFile) -> PathBuf
Sourcepub fn into_file_path_parts(
&self,
folder_id: &VaultId,
secret_id: &SecretId,
file_name: &ExternalFileName,
) -> PathBuf
pub fn into_file_path_parts( &self, folder_id: &VaultId, secret_id: &SecretId, file_name: &ExternalFileName, ) -> PathBuf
Sourcepub fn database_file(&self) -> &PathBuf
pub fn database_file(&self) -> &PathBuf
Path to the database file for an account.
Sourcepub fn into_blob_file_path(
&self,
vault_id: &VaultId,
secret_id: &SecretId,
file_name: impl AsRef<str>,
) -> PathBuf
pub fn into_blob_file_path( &self, vault_id: &VaultId, secret_id: &SecretId, file_name: impl AsRef<str>, ) -> PathBuf
Expected location for an external file blob.
§Panics
If this set of paths are global (no user identifier).
Sourcepub fn account_id(&self) -> Option<&AccountId>
pub fn account_id(&self) -> Option<&AccountId>
User identifier.
Sourcepub fn documents_dir(&self) -> &PathBuf
pub fn documents_dir(&self) -> &PathBuf
Top-level storage directory.
Sourcepub fn is_global(&self) -> bool
pub fn is_global(&self) -> bool
Determine if the paths are global.
Paths are global when a user identifier is not available.
Sourcepub fn identity_dir(&self) -> &PathBuf
pub fn identity_dir(&self) -> &PathBuf
Path to the identity vault directory.
Sourcepub fn audit_file(&self) -> &PathBuf
pub fn audit_file(&self) -> &PathBuf
Path to the audit file.
Sourcepub fn preferences_file(&self) -> PathBuf
pub fn preferences_file(&self) -> PathBuf
Path to the file used to store global or account-level preferences.
Sourcepub fn global_preferences_file(&self) -> PathBuf
pub fn global_preferences_file(&self) -> PathBuf
Path to the global preferences file.
Sourcepub fn system_messages_file(&self) -> PathBuf
pub fn system_messages_file(&self) -> PathBuf
Path to the file used to store account-level system messages.
§Panics
If this set of paths are global (no user identifier).
Sourcepub fn into_legacy_file_path(
&self,
vault_id: &VaultId,
secret_id: &SecretId,
file_name: impl AsRef<str>,
) -> PathBuf
pub fn into_legacy_file_path( &self, vault_id: &VaultId, secret_id: &SecretId, file_name: impl AsRef<str>, ) -> PathBuf
Sourcepub fn vaults_dir(&self) -> &PathBuf
pub fn vaults_dir(&self) -> &PathBuf
Sourcepub fn device_file(&self) -> &PathBuf
pub fn device_file(&self) -> &PathBuf
Sourcepub fn identity_vault(&self) -> PathBuf
pub fn identity_vault(&self) -> PathBuf
Path to the identity vault file for this user.
§Panics
If this set of paths are global (no user identifier).
Sourcepub fn identity_events(&self) -> PathBuf
pub fn identity_events(&self) -> PathBuf
Path to the identity events log for this user.
§Panics
If this set of paths are global (no user identifier).
Sourcepub fn vault_path(&self, id: &VaultId) -> PathBuf
pub fn vault_path(&self, id: &VaultId) -> PathBuf
Path to a vault file from it’s identifier.
§Panics
If this set of paths are global (no user identifier).
Sourcepub fn event_log_path(&self, id: &VaultId) -> PathBuf
pub fn event_log_path(&self, id: &VaultId) -> PathBuf
Path to an event log file from it’s identifier.
§Panics
If this set of paths are global (no user identifier).
Sourcepub fn account_events(&self) -> PathBuf
pub fn account_events(&self) -> PathBuf
Path to the user’s account event log file.
§Panics
If this set of paths are global (no user identifier).
Sourcepub fn device_events(&self) -> PathBuf
pub fn device_events(&self) -> PathBuf
Path to the user’s event log of device changes.
§Panics
If this set of paths are global (no user identifier).
Sourcepub fn file_events(&self) -> PathBuf
pub fn file_events(&self) -> PathBuf
Path to the user’s event log of external file changes.
§Panics
If this set of paths are global (no user identifier).
Sourcepub fn remote_origins(&self) -> PathBuf
pub fn remote_origins(&self) -> PathBuf
Path to the file used to store remote origins.
§Panics
If this set of paths are global (no user identifier).
Sourcepub async fn scaffold(
data_dir: impl Into<Option<&PathBuf>>,
) -> Result<(), Error>
pub async fn scaffold( data_dir: impl Into<Option<&PathBuf>>, ) -> Result<(), Error>
Ensure the root directories exist for storage.
Sourcepub fn set_data_dir(path: PathBuf)
pub fn set_data_dir(path: PathBuf)
Set an explicit data directory used to store all application files.
Sourcepub fn data_dir() -> Result<PathBuf, Error>
pub fn data_dir() -> Result<PathBuf, Error>
Get the default root directory used for caching application data.
If the SOS_DATA_DIR environment variable is set it is used.
Otherwise if an explicit directory has been set
using set_data_dir() then that will be used instead.
Finally if no environment variable or explicit directory has been set then a path will be computed by platform convention.
When running with debug_assertions a debug path is appended
(except when executing tests) so that we can use different
storage locations for debug and release builds.
If the SOS_TEST environment variable is set then we use
test rather than debug as the nested directory so that
test data does not collide with debug data.