Struct unidirs::ServiceDirs
source · pub struct ServiceDirs { /* private fields */ }
Expand description
Service directories are used for applications that run as a service (or often called 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§
source§impl ServiceDirs
impl ServiceDirs
sourcepub fn new(organization: impl AsRef<str>, application: impl AsRef<str>) -> Self
pub fn new(organization: impl AsRef<str>, application: impl AsRef<str>) -> Self
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§
source§impl Clone for ServiceDirs
impl Clone for ServiceDirs
source§fn clone(&self) -> ServiceDirs
fn clone(&self) -> ServiceDirs
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ServiceDirs
impl Debug for ServiceDirs
source§impl Directories for ServiceDirs
impl Directories for ServiceDirs
source§fn cache_dir(&self) -> &Utf8Path
fn cache_dir(&self) -> &Utf8Path
source§fn config_dir(&self) -> &Utf8Path
fn config_dir(&self) -> &Utf8Path
source§impl Hash for ServiceDirs
impl Hash for ServiceDirs
source§impl Ord for ServiceDirs
impl Ord for ServiceDirs
source§fn cmp(&self, other: &ServiceDirs) -> Ordering
fn cmp(&self, other: &ServiceDirs) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl PartialEq<ServiceDirs> for ServiceDirs
impl PartialEq<ServiceDirs> for ServiceDirs
source§fn eq(&self, other: &ServiceDirs) -> bool
fn eq(&self, other: &ServiceDirs) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<ServiceDirs> for ServiceDirs
impl PartialOrd<ServiceDirs> for ServiceDirs
source§fn partial_cmp(&self, other: &ServiceDirs) -> Option<Ordering>
fn partial_cmp(&self, other: &ServiceDirs) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more