pub struct SystemdDirs { /* private fields */ }Expand description
A struct to snapshot the environment at the time of creation.
The SystemdDirs methods return Path objects as immutable references to the paths as available when
Self::new was called. This differs from the standalone functions, which return PathBuf objects.
Implementations§
Source§impl SystemdDirs
impl SystemdDirs
Sourcepub fn new() -> Self
pub fn new() -> Self
Returns a new SystemdDirs struct with a snapshot of the current environment.
§Examples
use systemd_directories::SystemdDirs;
let dirs = SystemdDirs::new();Examples found in repository?
More examples
Sourcepub fn runtime_dirs(&self) -> Vec<&Path>
pub fn runtime_dirs(&self) -> Vec<&Path>
Returns all runtime directories as defined by RuntimeDirectory in the unit file.
If the environment variable RUNTIME_DIRECTORY was not set when SystemdDirs was created, it returns an empty vector.
If it was set, it returns all paths in the colon-separated list.
To get just the first path, use Self::runtime_dir.
§Examples
let dirs = systemd_directories::SystemdDirs::new();
let runtime_dirs = dirs.runtime_dirs();Sourcepub fn runtime_dir(&self) -> Option<&Path>
pub fn runtime_dir(&self) -> Option<&Path>
Returns the first runtime directory as defined by RuntimeDirectory in the unit file.
If the environment variable RUNTIME_DIRECTORY was not set when SystemdDirs was created, it returns None.
If it was set, it returns the first path in the colon-separated list.
To get all paths, use Self::runtime_dirs.
§Examples
let dirs = systemd_directories::SystemdDirs::new();
let runtime_dir = dirs.runtime_dir();Sourcepub fn state_dirs(&self) -> Vec<&Path>
pub fn state_dirs(&self) -> Vec<&Path>
Returns all state directories as defined by StateDirectory in the unit file.
If the environment variable STATE_DIRECTORY was not set when SystemdDirs was created, it returns an empty vector.
If it was set, it returns all paths in the colon-separated list.
To get just the first path, use Self::state_dir.
§Examples
let dirs = systemd_directories::SystemdDirs::new();
let state_dirs = dirs.state_dirs();Sourcepub fn state_dir(&self) -> Option<&Path>
pub fn state_dir(&self) -> Option<&Path>
Returns the first state directory as defined by StateDirectory in the unit file.
If the environment variable STATE_DIRECTORY was not set when SystemdDirs was created, it returns None.
If it was set, it returns the first path in the colon-separated list.
To get all paths, use Self::state_dirs.
§Examples
let dirs = systemd_directories::SystemdDirs::new();
let state_dir = dirs.state_dir();Sourcepub fn cache_dirs(&self) -> Vec<&Path>
pub fn cache_dirs(&self) -> Vec<&Path>
Returns all cache directories as defined by CacheDirectory in the unit file.
If the environment variable CACHE_DIRECTORY was not set when SystemdDirs was created, it returns an empty vector.
If it was set, it returns all paths in the colon-separated list.
To get just the first path, use Self::cache_dir.
§Examples
let dirs = systemd_directories::SystemdDirs::new();
let cache_dirs = dirs.cache_dirs();Sourcepub fn cache_dir(&self) -> Option<&Path>
pub fn cache_dir(&self) -> Option<&Path>
Returns the first cache directory as defined by CacheDirectory in the unit file.
If the environment variable CACHE_DIRECTORY was not set when SystemdDirs was created, it returns None.
If it was set, it returns the first path in the colon-separated list.
To get all paths, use Self::cache_dirs.
§Examples
let dirs = systemd_directories::SystemdDirs::new();
let cache_dir = dirs.cache_dir();Sourcepub fn logs_dirs(&self) -> Vec<&Path>
pub fn logs_dirs(&self) -> Vec<&Path>
Returns all logs directories as defined by LogsDirectory in the unit file.
If the environment variable LOGS_DIRECTORY was not set when SystemdDirs was created, it returns an empty vector.
If it was set, it returns all paths in the colon-separated list.
To get just the first path, use Self::logs_dir.
§Examples
let dirs = systemd_directories::SystemdDirs::new();
let logs_dirs = dirs.logs_dirs();Sourcepub fn logs_dir(&self) -> Option<&Path>
pub fn logs_dir(&self) -> Option<&Path>
Returns the first logs directory as defined by LogsDirectory in the unit file.
If the environment variable LOGS_DIRECTORY was not set when SystemdDirs was created, it returns None.
If it was set, it returns the first path in the colon-separated list.
To get all paths, use Self::logs_dirs.
§Examples
let dirs = systemd_directories::SystemdDirs::new();
let logs_dir = dirs.logs_dir();Sourcepub fn config_dirs(&self) -> Vec<&Path>
pub fn config_dirs(&self) -> Vec<&Path>
Returns all configuration directories as defined by ConfigurationDirectory in the unit file.
If the environment variable CONFIGURATION_DIRECTORY was not set when SystemdDirs was created, it returns an empty vector.
If it was set, it returns all paths in the colon-separated list.
To get just the first path, use Self::config_dir.
§Examples
let dirs = systemd_directories::SystemdDirs::new();
let config_dirs = dirs.config_dirs();Sourcepub fn config_dir(&self) -> Option<&Path>
pub fn config_dir(&self) -> Option<&Path>
Returns the first configuration directory as defined by ConfigurationDirectory in the unit file.
If the environment variable CONFIGURATION_DIRECTORY was not set when SystemdDirs was created, it returns None.
If it was set, it returns the first path in the colon-separated list.
To get all paths, use Self::config_dirs.
§Examples
let dirs = systemd_directories::SystemdDirs::new();
let config_dir = dirs.config_dir();Trait Implementations§
Source§impl Clone for SystemdDirs
impl Clone for SystemdDirs
Source§fn clone(&self) -> SystemdDirs
fn clone(&self) -> SystemdDirs
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more