XDG

Struct XDG 

Source
pub struct XDG { /* private fields */ }

Methods from Deref<Target = BaseDirectories>§

Source

pub fn get_runtime_directory(&self) -> Result<&PathBuf, Error>

Returns the user-specific runtime directory (set by XDG_RUNTIME_DIR).

Source

pub fn has_runtime_directory(&self) -> bool

Returns true if XDG_RUNTIME_DIR is available, false otherwise.

Source

pub fn get_config_file<P>(&self, path: P) -> PathBuf
where P: AsRef<Path>,

Like place_config_file(), but does not create any directories.

Source

pub fn get_data_file<P>(&self, path: P) -> PathBuf
where P: AsRef<Path>,

Like place_data_file(), but does not create any directories.

Source

pub fn get_cache_file<P>(&self, path: P) -> PathBuf
where P: AsRef<Path>,

Like place_cache_file(), but does not create any directories.

Source

pub fn get_state_file<P>(&self, path: P) -> PathBuf
where P: AsRef<Path>,

Like place_state_file(), but does not create any directories.

Source

pub fn get_runtime_file<P>(&self, path: P) -> Result<PathBuf, Error>
where P: AsRef<Path>,

Like place_runtime_file(), but does not create any directories. If XDG_RUNTIME_DIR is not available, returns an error.

Source

pub fn place_config_file<P>(&self, path: P) -> Result<PathBuf, Error>
where P: AsRef<Path>,

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.

Source

pub fn place_data_file<P>(&self, path: P) -> Result<PathBuf, Error>
where P: AsRef<Path>,

Like place_config_file(), but for a data file in XDG_DATA_HOME.

Source

pub fn place_cache_file<P>(&self, path: P) -> Result<PathBuf, Error>
where P: AsRef<Path>,

Like place_config_file(), but for a cache file in XDG_CACHE_HOME.

Source

pub fn place_state_file<P>(&self, path: P) -> Result<PathBuf, Error>
where P: AsRef<Path>,

Like place_config_file(), but for an application state file in XDG_STATE_HOME.

Source

pub fn place_runtime_file<P>(&self, path: P) -> Result<PathBuf, Error>
where P: AsRef<Path>,

Like place_config_file(), but for a runtime file in XDG_RUNTIME_DIR. If XDG_RUNTIME_DIR is not available, returns an error.

Source

pub fn find_config_file<P>(&self, path: P) -> Option<PathBuf>
where P: AsRef<Path>,

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.

Source

pub fn find_config_files<P>(&self, path: P) -> FileFindIterator
where P: AsRef<Path>,

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.

Source

pub fn find_data_file<P>(&self, path: P) -> Option<PathBuf>
where P: AsRef<Path>,

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.

Source

pub fn find_data_files<P>(&self, path: P) -> FileFindIterator
where P: AsRef<Path>,

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.

Source

pub fn find_cache_file<P>(&self, path: P) -> Option<PathBuf>
where P: AsRef<Path>,

Given a relative path path, returns an absolute path to an existing cache file, or None. Searches XDG_CACHE_HOME.

Source

pub fn find_state_file<P>(&self, path: P) -> Option<PathBuf>
where P: AsRef<Path>,

Given a relative path path, returns an absolute path to an existing application state file, or None. Searches XDG_STATE_HOME.

Source

pub fn find_runtime_file<P>(&self, path: P) -> Option<PathBuf>
where P: AsRef<Path>,

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.

Source

pub fn create_config_directory<P>(&self, path: P) -> Result<PathBuf, Error>
where P: AsRef<Path>,

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.

Source

pub fn create_data_directory<P>(&self, path: P) -> Result<PathBuf, Error>
where P: AsRef<Path>,

Like create_config_directory(), but for a data directory in XDG_DATA_HOME.

Source

pub fn create_cache_directory<P>(&self, path: P) -> Result<PathBuf, Error>
where P: AsRef<Path>,

Like create_config_directory(), but for a cache directory in XDG_CACHE_HOME.

Source

pub fn create_state_directory<P>(&self, path: P) -> Result<PathBuf, Error>
where P: AsRef<Path>,

Like create_config_directory(), but for an application state directory in XDG_STATE_HOME.

Source

pub fn create_runtime_directory<P>(&self, path: P) -> Result<PathBuf, Error>
where P: AsRef<Path>,

Like create_config_directory(), but for a runtime directory in XDG_RUNTIME_DIR. If XDG_RUNTIME_DIR is not available, returns an error.

Source

pub fn list_config_files<P>(&self, path: P) -> Vec<PathBuf>
where P: AsRef<Path>,

Given a relative path path, list absolute paths to all files in directories with path path in XDG_CONFIG_HOME and XDG_CONFIG_DIRS.

Source

pub fn list_config_files_once<P>(&self, path: P) -> Vec<PathBuf>
where P: AsRef<Path>,

Like list_config_files, but only the first occurence of every distinct filename is returned.

Source

pub fn list_data_files<P>(&self, path: P) -> Vec<PathBuf>
where P: AsRef<Path>,

Given a relative path path, lists absolute paths to all files in directories with path path in XDG_DATA_HOME and XDG_DATA_DIRS.

Source

pub fn list_data_files_once<P>(&self, path: P) -> Vec<PathBuf>
where P: AsRef<Path>,

Like list_data_files, but only the first occurence of every distinct filename is returned.

Source

pub fn list_cache_files<P>(&self, path: P) -> Vec<PathBuf>
where P: AsRef<Path>,

Given a relative path path, lists absolute paths to all files in directories with path path in XDG_CACHE_HOME.

Source

pub fn list_state_files<P>(&self, path: P) -> Vec<PathBuf>
where P: AsRef<Path>,

Given a relative path path, lists absolute paths to all files in directories with path path in XDG_STATE_HOME.

Source

pub fn list_runtime_files<P>(&self, path: P) -> Vec<PathBuf>
where P: AsRef<Path>,

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.

Source

pub fn get_data_home(&self) -> PathBuf

Returns the user-specific data directory (set by XDG_DATA_HOME).

Source

pub fn get_config_home(&self) -> PathBuf

Returns the user-specific configuration directory (set by XDG_CONFIG_HOME).

Source

pub fn get_cache_home(&self) -> PathBuf

Returns the user-specific directory for non-essential (cached) data (set by XDG_CACHE_HOME).

Source

pub fn get_state_home(&self) -> PathBuf

Returns the user-specific directory for application state data (set by XDG_STATE_HOME).

Source

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).

Source

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).

Trait Implementations§

Source§

impl Deref for XDG

Source§

type Target = BaseDirectories

The resulting type after dereferencing.
Source§

fn deref(&self) -> &BaseDirectories

Dereferences the value.
Source§

impl LazyStatic for XDG

Auto Trait Implementations§

§

impl Freeze for XDG

§

impl RefUnwindSafe for XDG

§

impl Send for XDG

§

impl Sync for XDG

§

impl Unpin for XDG

§

impl UnwindSafe for XDG

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more