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.
Type | Location |
---|---|
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.
Type | Location |
---|---|
Cache | C:\Windows\ServiceProfiles\NetworkService\AppData\<org> \<app> \Local\cache |
Config | C:\Windows\ServiceProfiles\NetworkService\AppData\<org> \<app> \Roaming\config |
Data | C:\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
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
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
Auto Trait Implementations
impl RefUnwindSafe for ServiceDirs
impl Send for ServiceDirs
impl Sync for ServiceDirs
impl Unpin for ServiceDirs
impl UnwindSafe for ServiceDirs
Blanket Implementations
Mutably borrows from an owned value. Read more