Struct etcetera::app_strategy::Unix
source · pub struct Unix { /* private fields */ }
Expand description
This strategy has no standard or official specification. It has arisen over time through hundreds of Unixy tools. Vim and Cargo are notable examples whose configuration/data/cache directory layouts are similar to those created by this strategy.
use etcetera::app_strategy::AppStrategy;
use etcetera::app_strategy::AppStrategyArgs;
use etcetera::app_strategy::Unix;
use std::path::Path;
let app_strategy = Unix::new(AppStrategyArgs {
top_level_domain: "org".to_string(),
author: "Acme Corp".to_string(),
app_name: "Frobnicator Plus".to_string(),
}).unwrap();
let home_dir = etcetera::home_dir().unwrap();
assert_eq!(
app_strategy.home_dir(),
&home_dir
);
assert_eq!(
app_strategy.config_dir().strip_prefix(&home_dir),
Ok(Path::new(".frobnicator-plus/"))
);
assert_eq!(
app_strategy.data_dir().strip_prefix(&home_dir),
Ok(Path::new(".frobnicator-plus/data/"))
);
assert_eq!(
app_strategy.cache_dir().strip_prefix(&home_dir),
Ok(Path::new(".frobnicator-plus/cache/"))
);
assert_eq!(
app_strategy.state_dir().unwrap().strip_prefix(&home_dir),
Ok(Path::new(".frobnicator-plus/state/"))
);
assert_eq!(
app_strategy.runtime_dir().unwrap().strip_prefix(&home_dir),
Ok(Path::new(".frobnicator-plus/runtime/"))
);
Trait Implementations§
source§impl AppStrategy for Unix
impl AppStrategy for Unix
§type CreationError = HomeDirError
type CreationError = HomeDirError
The error type returned by
new
.source§fn 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.
source§fn config_dir(&self) -> PathBuf
fn config_dir(&self) -> PathBuf
Gets the configuration directory for your application.
source§fn 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.
source§fn 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.
source§fn 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.
source§fn 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.
source§fn 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.
source§impl Ord for Unix
impl Ord for Unix
source§impl PartialEq<Unix> for Unix
impl PartialEq<Unix> for Unix
source§impl PartialOrd<Unix> for Unix
impl PartialOrd<Unix> for Unix
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Unix
impl StructuralEq for Unix
impl StructuralPartialEq for Unix
Auto Trait Implementations§
impl RefUnwindSafe for Unix
impl Send for Unix
impl Sync for Unix
impl Unpin for Unix
impl UnwindSafe for Unix
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more