AppStrategy

Trait AppStrategy 

Source
pub trait AppStrategy {
    // Required methods
    fn home_dir(&self) -> &Path;
    fn config_dir(&self) -> PathBuf;
    fn data_dir(&self) -> PathBuf;
    fn cache_dir(&self) -> PathBuf;
    fn state_dir(&self) -> Option<PathBuf>;
    fn runtime_dir(&self) -> Option<PathBuf>;

    // Provided methods
    fn in_config_dir<P: AsRef<OsStr>>(&self, path: P) -> PathBuf { ... }
    fn in_data_dir<P: AsRef<OsStr>>(&self, path: P) -> PathBuf { ... }
    fn in_cache_dir<P: AsRef<OsStr>>(&self, path: P) -> PathBuf { ... }
    fn in_state_dir<P: AsRef<OsStr>>(&self, path: P) -> Option<PathBuf> { ... }
    fn in_runtime_dir<P: AsRef<OsStr>>(&self, path: P) -> Option<PathBuf> { ... }
}
Expand description

Allows applications to retrieve the paths of configuration, data, and cache directories specifically for them.

Required Methods§

Source

fn home_dir(&self) -> &Path

Gets the home directory of the current user.

Source

fn config_dir(&self) -> PathBuf

Gets the configuration directory for your application.

Source

fn data_dir(&self) -> PathBuf

Gets the data directory for your application.

Source

fn cache_dir(&self) -> PathBuf

Gets the cache directory for your application.

Source

fn state_dir(&self) -> Option<PathBuf>

Gets the state directory for your application. Currently, only the Xdg & Unix strategies support this.

Source

fn runtime_dir(&self) -> Option<PathBuf>

Gets the runtime directory for your application. Currently, only the Xdg & Unix strategies support this.

Note: The XDG Base Directory Specification places additional requirements on this directory related to ownership, permissions, and persistence. This library does not check these requirements.

Provided Methods§

Source

fn in_config_dir<P: AsRef<OsStr>>(&self, path: P) -> PathBuf

Constructs a path inside your application’s configuration directory to which a path of your choice has been appended.

Source

fn in_data_dir<P: AsRef<OsStr>>(&self, path: P) -> PathBuf

Constructs a path inside your application’s data directory to which a path of your choice has been appended.

Source

fn in_cache_dir<P: AsRef<OsStr>>(&self, path: P) -> PathBuf

Constructs a path inside your application’s cache directory to which a path of your choice has been appended.

Source

fn in_state_dir<P: AsRef<OsStr>>(&self, path: P) -> Option<PathBuf>

Constructs a path inside your application’s state directory to which a path of your choice has been appended.

Currently, this is only implemented for the Xdg strategy.

Source

fn in_runtime_dir<P: AsRef<OsStr>>(&self, path: P) -> Option<PathBuf>

Constructs a path inside your application’s runtime directory to which a path of your choice has been appended. Currently, only the Xdg & Unix strategies support this.

See the note in runtime_dir for more information.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§