Trait etcetera::app_strategy::AppStrategy
source · 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§
sourcetype CreationError: Error
type CreationError: Error
The error type returned by new
.
Required Methods§
sourcefn new(args: AppStrategyArgs) -> Result<Self, Self::CreationError>
fn new(args: AppStrategyArgs) -> Result<Self, Self::CreationError>
The constructor requires access to some basic information about your application.
sourcefn config_dir(&self) -> PathBuf
fn config_dir(&self) -> PathBuf
Gets the configuration directory for your application.
sourcefn state_dir(&self) -> Option<PathBuf>
fn state_dir(&self) -> Option<PathBuf>
Gets the state directory for your application. State directory may not to exist for all conventions.
sourcefn runtime_dir(&self) -> Option<PathBuf>
fn runtime_dir(&self) -> Option<PathBuf>
Gets the runtime directory for your application. Runtime directory may not to exist for all conventions.
Provided Methods§
sourcefn in_config_dir<P: AsRef<OsStr>>(&self, path: P) -> PathBuf
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.
sourcefn in_data_dir<P: AsRef<OsStr>>(&self, path: P) -> PathBuf
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.
sourcefn in_cache_dir<P: AsRef<OsStr>>(&self, path: P) -> PathBuf
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.