pub fn state_dir() -> Option<PathBuf>Expand description
Returns the first state directory as defined by StateDirectory in the unit file.
If the environment variable STATE_DIRECTORY is not set, it returns None.
If it is set, it returns the first path in the colon-separated list.
To get all paths, use state_dirs.
ยงExamples
let state_dir = systemd_directories::state_dir().unwrap_or_default();The function returns Option<PathBuf> which can be used in if let statements to handle the case where the environment variable is not set.
if let Some(state_dir) = systemd_directories::state_dir() {
// --snip--
}