pub struct XDG { /* private fields */ }Methods from Deref<Target = BaseDirectories>§
Sourcepub fn get_runtime_directory(&self) -> Result<&PathBuf, Error>
pub fn get_runtime_directory(&self) -> Result<&PathBuf, Error>
Returns the user-specific runtime directory (set by XDG_RUNTIME_DIR).
Sourcepub fn has_runtime_directory(&self) -> bool
pub fn has_runtime_directory(&self) -> bool
Returns true if XDG_RUNTIME_DIR is available, false otherwise.
Sourcepub fn get_config_file<P>(&self, path: P) -> PathBuf
pub fn get_config_file<P>(&self, path: P) -> PathBuf
Like place_config_file(), but does
not create any directories.
Sourcepub fn get_data_file<P>(&self, path: P) -> PathBuf
pub fn get_data_file<P>(&self, path: P) -> PathBuf
Like place_data_file(), but does
not create any directories.
Sourcepub fn get_cache_file<P>(&self, path: P) -> PathBuf
pub fn get_cache_file<P>(&self, path: P) -> PathBuf
Like place_cache_file(), but does
not create any directories.
Sourcepub fn get_state_file<P>(&self, path: P) -> PathBuf
pub fn get_state_file<P>(&self, path: P) -> PathBuf
Like place_state_file(), but does
not create any directories.
Sourcepub fn get_runtime_file<P>(&self, path: P) -> Result<PathBuf, Error>
pub fn get_runtime_file<P>(&self, path: P) -> Result<PathBuf, Error>
Like place_runtime_file(), but does
not create any directories.
If XDG_RUNTIME_DIR is not available, returns an error.
Sourcepub fn place_config_file<P>(&self, path: P) -> Result<PathBuf, Error>
pub fn place_config_file<P>(&self, path: P) -> Result<PathBuf, Error>
Given a relative path path, returns an absolute path in
XDG_CONFIG_HOME where a configuration file may be stored.
Leading directories in the returned path are pre-created;
if that is not possible, an error is returned.
Sourcepub fn place_data_file<P>(&self, path: P) -> Result<PathBuf, Error>
pub fn place_data_file<P>(&self, path: P) -> Result<PathBuf, Error>
Like place_config_file(), but for
a data file in XDG_DATA_HOME.
Sourcepub fn place_cache_file<P>(&self, path: P) -> Result<PathBuf, Error>
pub fn place_cache_file<P>(&self, path: P) -> Result<PathBuf, Error>
Like place_config_file(), but for
a cache file in XDG_CACHE_HOME.
Sourcepub fn place_state_file<P>(&self, path: P) -> Result<PathBuf, Error>
pub fn place_state_file<P>(&self, path: P) -> Result<PathBuf, Error>
Like place_config_file(), but for
an application state file in XDG_STATE_HOME.
Sourcepub fn place_runtime_file<P>(&self, path: P) -> Result<PathBuf, Error>
pub fn place_runtime_file<P>(&self, path: P) -> Result<PathBuf, Error>
Like place_config_file(), but for
a runtime file in XDG_RUNTIME_DIR.
If XDG_RUNTIME_DIR is not available, returns an error.
Sourcepub fn find_config_file<P>(&self, path: P) -> Option<PathBuf>
pub fn find_config_file<P>(&self, path: P) -> Option<PathBuf>
Given a relative path path, returns an absolute path to an existing
configuration file, or None. Searches XDG_CONFIG_HOME and then
XDG_CONFIG_DIRS.
Sourcepub fn find_config_files<P>(&self, path: P) -> FileFindIterator
pub fn find_config_files<P>(&self, path: P) -> FileFindIterator
Given a relative path path, returns an iterator yielding absolute
paths to existing configuration files, in XDG_CONFIG_DIRS and
XDG_CONFIG_HOME. Paths are produced in order from lowest priority
to highest.
Sourcepub fn find_data_file<P>(&self, path: P) -> Option<PathBuf>
pub fn find_data_file<P>(&self, path: P) -> Option<PathBuf>
Given a relative path path, returns an absolute path to an existing
data file, or None. Searches XDG_DATA_HOME and then
XDG_DATA_DIRS.
Sourcepub fn find_data_files<P>(&self, path: P) -> FileFindIterator
pub fn find_data_files<P>(&self, path: P) -> FileFindIterator
Given a relative path path, returns an iterator yielding absolute
paths to existing data files, in XDG_DATA_DIRS and
XDG_DATA_HOME. Paths are produced in order from lowest priority
to highest.
Sourcepub fn find_cache_file<P>(&self, path: P) -> Option<PathBuf>
pub fn find_cache_file<P>(&self, path: P) -> Option<PathBuf>
Given a relative path path, returns an absolute path to an existing
cache file, or None. Searches XDG_CACHE_HOME.
Sourcepub fn find_state_file<P>(&self, path: P) -> Option<PathBuf>
pub fn find_state_file<P>(&self, path: P) -> Option<PathBuf>
Given a relative path path, returns an absolute path to an existing
application state file, or None. Searches XDG_STATE_HOME.
Sourcepub fn find_runtime_file<P>(&self, path: P) -> Option<PathBuf>
pub fn find_runtime_file<P>(&self, path: P) -> Option<PathBuf>
Given a relative path path, returns an absolute path to an existing
runtime file, or None. Searches XDG_RUNTIME_DIR.
If XDG_RUNTIME_DIR is not available, returns None.
Sourcepub fn create_config_directory<P>(&self, path: P) -> Result<PathBuf, Error>
pub fn create_config_directory<P>(&self, path: P) -> Result<PathBuf, Error>
Given a relative path path, returns an absolute path to a configuration
directory in XDG_CONFIG_HOME. The directory and all directories
leading to it are created if they did not exist;
if that is not possible, an error is returned.
Sourcepub fn create_data_directory<P>(&self, path: P) -> Result<PathBuf, Error>
pub fn create_data_directory<P>(&self, path: P) -> Result<PathBuf, Error>
Like create_config_directory(),
but for a data directory in XDG_DATA_HOME.
Sourcepub fn create_cache_directory<P>(&self, path: P) -> Result<PathBuf, Error>
pub fn create_cache_directory<P>(&self, path: P) -> Result<PathBuf, Error>
Like create_config_directory(),
but for a cache directory in XDG_CACHE_HOME.
Sourcepub fn create_state_directory<P>(&self, path: P) -> Result<PathBuf, Error>
pub fn create_state_directory<P>(&self, path: P) -> Result<PathBuf, Error>
Like create_config_directory(),
but for an application state directory in XDG_STATE_HOME.
Sourcepub fn create_runtime_directory<P>(&self, path: P) -> Result<PathBuf, Error>
pub fn create_runtime_directory<P>(&self, path: P) -> Result<PathBuf, Error>
Like create_config_directory(),
but for a runtime directory in XDG_RUNTIME_DIR.
If XDG_RUNTIME_DIR is not available, returns an error.
Sourcepub fn list_config_files<P>(&self, path: P) -> Vec<PathBuf>
pub fn list_config_files<P>(&self, path: P) -> Vec<PathBuf>
Given a relative path path, list absolute paths to all files
in directories with path path in XDG_CONFIG_HOME and
XDG_CONFIG_DIRS.
Sourcepub fn list_config_files_once<P>(&self, path: P) -> Vec<PathBuf>
pub fn list_config_files_once<P>(&self, path: P) -> Vec<PathBuf>
Like list_config_files, but
only the first occurence of every distinct filename is returned.
Sourcepub fn list_data_files<P>(&self, path: P) -> Vec<PathBuf>
pub fn list_data_files<P>(&self, path: P) -> Vec<PathBuf>
Given a relative path path, lists absolute paths to all files
in directories with path path in XDG_DATA_HOME and
XDG_DATA_DIRS.
Sourcepub fn list_data_files_once<P>(&self, path: P) -> Vec<PathBuf>
pub fn list_data_files_once<P>(&self, path: P) -> Vec<PathBuf>
Like list_data_files, but
only the first occurence of every distinct filename is returned.
Sourcepub fn list_cache_files<P>(&self, path: P) -> Vec<PathBuf>
pub fn list_cache_files<P>(&self, path: P) -> Vec<PathBuf>
Given a relative path path, lists absolute paths to all files
in directories with path path in XDG_CACHE_HOME.
Sourcepub fn list_state_files<P>(&self, path: P) -> Vec<PathBuf>
pub fn list_state_files<P>(&self, path: P) -> Vec<PathBuf>
Given a relative path path, lists absolute paths to all files
in directories with path path in XDG_STATE_HOME.
Sourcepub fn list_runtime_files<P>(&self, path: P) -> Vec<PathBuf>
pub fn list_runtime_files<P>(&self, path: P) -> Vec<PathBuf>
Given a relative path path, lists absolute paths to all files
in directories with path path in XDG_RUNTIME_DIR.
If XDG_RUNTIME_DIR is not available, returns an empty Vec.
Sourcepub fn get_data_home(&self) -> PathBuf
pub fn get_data_home(&self) -> PathBuf
Returns the user-specific data directory (set by XDG_DATA_HOME).
Sourcepub fn get_config_home(&self) -> PathBuf
pub fn get_config_home(&self) -> PathBuf
Returns the user-specific configuration directory (set by
XDG_CONFIG_HOME).
Sourcepub fn get_cache_home(&self) -> PathBuf
pub fn get_cache_home(&self) -> PathBuf
Returns the user-specific directory for non-essential (cached) data
(set by XDG_CACHE_HOME).
Sourcepub fn get_state_home(&self) -> PathBuf
pub fn get_state_home(&self) -> PathBuf
Returns the user-specific directory for application state data
(set by XDG_STATE_HOME).
Sourcepub fn get_data_dirs(&self) -> Vec<PathBuf>
pub fn get_data_dirs(&self) -> Vec<PathBuf>
Returns a preference ordered (preferred to less preferred) list of
supplementary data directories, ordered by preference (set by
XDG_DATA_DIRS).
Sourcepub fn get_config_dirs(&self) -> Vec<PathBuf>
pub fn get_config_dirs(&self) -> Vec<PathBuf>
Returns a preference ordered (preferred to less preferred) list of
supplementary configuration directories (set by XDG_CONFIG_DIRS).