pub trait AppStrategy: Sized {
    type CreationError: Error;

    // Required methods
    fn new(args: AppStrategyArgs) -> Result<Self, Self::CreationError>;
    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 Associated Types§

source

type CreationError: Error

The error type returned by new.

Required Methods§

source

fn new(args: AppStrategyArgs) -> Result<Self, Self::CreationError>

The constructor requires access to some basic information about your application.

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. State directory may not to exist for all conventions.

source

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

Gets the runtime directory for your application. Runtime directory may not to exist for all conventions.

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.

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.

Implementors§