Paths

Struct Paths 

Source
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

Source

pub fn new_client(documents_dir: impl AsRef<Path>) -> Arc<Self>

Create paths for a client without an account identifier.

Source

pub fn new_server(documents_dir: impl AsRef<Path>) -> Arc<Self>

Create paths for a server without an account identifier.

Source

pub fn is_server(&self) -> bool

Whether these paths are for server-side storage.

Source

pub fn with_account_id(&self, account_id: &AccountId) -> Arc<Self>

Clone of paths with an account identifier.

Source

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.

Source

pub fn is_using_db(&self) -> bool

Determine if a database file exists.

Source

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.

Source

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).

Source

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).

Source

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).

Source

pub fn into_file_path(&self, file: &ExternalFile) -> PathBuf

External file path.

§Panics

If this set of paths are global (no user identifier).

Source

pub fn into_file_path_parts( &self, folder_id: &VaultId, secret_id: &SecretId, file_name: &ExternalFileName, ) -> PathBuf

External file path from parts.

§Panics

If this set of paths are global (no user identifier).

Source

pub fn database_file(&self) -> &PathBuf

Path to the database file for an account.

Source

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).

Source

pub fn account_id(&self) -> Option<&AccountId>

User identifier.

Source

pub fn documents_dir(&self) -> &PathBuf

Top-level storage directory.

Source

pub fn is_global(&self) -> bool

Determine if the paths are global.

Paths are global when a user identifier is not available.

Source

pub fn identity_dir(&self) -> &PathBuf

Path to the identity vault directory.

Source

pub fn local_dir(&self) -> &PathBuf

Path to the local storage.

Source

pub fn logs_dir(&self) -> &PathBuf

Path to the logs directory.

Source

pub fn audit_file(&self) -> &PathBuf

Path to the audit file.

Source

pub fn preferences_file(&self) -> PathBuf

Path to the file used to store global or account-level preferences.

Source

pub fn global_preferences_file(&self) -> PathBuf

Path to the global preferences file.

Source

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).

Source

pub fn user_dir(&self) -> &PathBuf

User specific storage directory.

§Panics

If this set of paths are global (no user identifier).

Source

pub fn files_dir(&self) -> &PathBuf

User’s files directory.

§Panics

If this set of paths are global (no user identifier).

Source

pub fn into_legacy_file_path( &self, vault_id: &VaultId, secret_id: &SecretId, file_name: impl AsRef<str>, ) -> PathBuf

Expected location for a file.

§Panics

If this set of paths are global (no user identifier).

Source

pub fn vaults_dir(&self) -> &PathBuf

User’s vaults storage directory.

§Panics

If this set of paths are global (no user identifier).

Source

pub fn device_file(&self) -> &PathBuf

User’s device signing key vault file.

§Panics

If this set of paths are global (no user identifier).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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).

Source

pub async fn scaffold( data_dir: impl Into<Option<&PathBuf>>, ) -> Result<(), Error>

Ensure the root directories exist for storage.

Source

pub fn set_data_dir(path: PathBuf)

Set an explicit data directory used to store all application files.

Source

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.

Trait Implementations§

Source§

impl Clone for Paths

Source§

fn clone(&self) -> Paths

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 Debug for Paths

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Paths

Source§

fn default() -> Paths

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Paths

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Paths

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Paths

§

impl RefUnwindSafe for Paths

§

impl Send for Paths

§

impl Sync for Paths

§

impl Unpin for Paths

§

impl UnwindSafe for Paths

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, 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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