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(documents_dir: impl AsRef<Path>, user_id: impl AsRef<str>) -> Self
pub fn new(documents_dir: impl AsRef<Path>, user_id: impl AsRef<str>) -> Self
Create new paths for a client.
Sourcepub fn new_server(
documents_dir: impl AsRef<Path>,
user_id: impl AsRef<str>,
) -> Self
pub fn new_server( documents_dir: impl AsRef<Path>, user_id: impl AsRef<str>, ) -> Self
Create new paths for a server.
Sourcepub fn new_global(documents_dir: impl AsRef<Path>) -> Self
pub fn new_global(documents_dir: impl AsRef<Path>) -> Self
Create new paths for a client with an empty user identifier.
Used to get application level paths when a user identifier is not available.
Sourcepub fn new_global_server(documents_dir: impl AsRef<Path>) -> Self
pub fn new_global_server(documents_dir: impl AsRef<Path>) -> Self
Create new paths for a client with an empty user identifier.
Used to get application level paths when a user identifier is not available.
Sourcepub fn with_account_id(&self, account_id: &AccountId) -> Self
pub fn with_account_id(&self, account_id: &AccountId) -> 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 async fn ensure_db(&self) -> Result<(), Error>
pub async fn ensure_db(&self) -> Result<(), Error>
Ensure the local storage directory exists for version 2 database storage.
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 database_file(&self) -> &PathBuf
pub fn database_file(&self) -> &PathBuf
Sourcepub fn blobs_account_dir(&self) -> PathBuf
pub fn blobs_account_dir(&self) -> PathBuf
Expected location for the directory containing all the external file blobs for an account.
§Panics
If this set of paths are global (no user identifier).
Sourcepub fn blob_folder_location(&self, vault_id: &VaultId) -> PathBuf
pub fn blob_folder_location(&self, vault_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 blob_location(
&self,
vault_id: &VaultId,
secret_id: &SecretId,
file_name: impl AsRef<str>,
) -> PathBuf
pub fn blob_location( &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 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 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 file_folder_location(&self, vault_id: &VaultId) -> PathBuf
pub fn file_folder_location(&self, vault_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 file_location(
&self,
vault_id: &VaultId,
secret_id: &SecretId,
file_name: impl AsRef<str>,
) -> PathBuf
pub fn file_location( &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: Option<PathBuf>) -> Result<(), Error>
pub async fn scaffold(data_dir: Option<PathBuf>) -> Result<(), Error>
Ensure the root directories exist for file system storage.
Sourcepub async fn scaffold_db(data_dir: Option<PathBuf>) -> Result<(), Error>
pub async fn scaffold_db(data_dir: Option<PathBuf>) -> Result<(), Error>
Ensure the root directories exist for database 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 clear_data_dir()
pub fn clear_data_dir()
Clear an explicitly set data directory.
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.