Struct unidirs::ServiceDirs[][src]

pub struct ServiceDirs { /* fields omitted */ }
Expand description

Service directories are used for applications that run as a service (or often call daemon), usually run by a dedicated user account and controlled by the system rather than the user.

The directories are therefore rather global and close to the system instead of being located in the user’s home directory.

Unix (Linux, Mac OS and others)

On Unix systems the service folders are mostly standardized. Depending on how a service is run on Mac OS, the UserDirs might be correct as well, but for system-run services the correct folders are the same as on other Unix systems.

TypeLocation
Cache/var/cache/<app>
Config/etc/<app>
Data/var/lib/<app>

Windows

On Windows there are three standard service accounts: LocalService, NetworkService and LocalSystem. These present different capabilities and a network service provides a middle ground with minimal capabilities plus networking access.

The API might be extended to pick the type of service account in the future.

TypeLocation
CacheC:\Windows\ServiceProfiles\NetworkService\AppData\<org>\<app>\Local\cache
ConfigC:\Windows\ServiceProfiles\NetworkService\AppData\<org>\<app>\Roaming\config
DataC:\Windows\ServiceProfiles\NetworkService\AppData\<org>\<app>\Roaming\data

Implementations

Create a new instance with the given organization and application name. The organization name is only used on Windows systems.

Examples
use unidirs::{Directories, ServiceDirs};

let dirs = ServiceDirs::new("example", "app");

println!("data_dir = {}", dirs.data_dir());
// On Unix:    /var/lib/app
// On Windows: C:\Windows\ServiceProfiles\NetworkService\AppData\example\app\data

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The cache directory is a location where an application can save any temporary data. The contents can potentially be deleted by the system at any time. Therefore, the application must be able to work without these files or be able to re-create them. Read more

The config directory is where an application’s settings are stored. These are usually created by the user and loaded once at startup of the application. Read more

The data directory hold an application’s state data, like a database. The folder is expected to persist during the normal runtime of the OS. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.