pub struct Apple { /* private fields */ }Expand description
This is the strategy created by Apple for use on macOS and iOS devices. It is always used by GUI apps on macOS, and is sometimes used by command-line applications there too. iOS only has GUIs, so all iOS applications follow this strategy. The specification is available here.
use etcetera::app_strategy::AppStrategy;
use etcetera::app_strategy::AppStrategyArgs;
use etcetera::app_strategy::Apple;
use std::path::Path;
let app_strategy = Apple::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("Library/Preferences/org.acme-corp.Frobnicator-Plus/"))
);
assert_eq!(
app_strategy.data_dir().strip_prefix(&home_dir),
Ok(Path::new("Library/Application Support/org.acme-corp.Frobnicator-Plus/"))
);
assert_eq!(
app_strategy.cache_dir().strip_prefix(&home_dir),
Ok(Path::new("Library/Caches/org.acme-corp.Frobnicator-Plus/"))
);
assert_eq!(
app_strategy.state_dir(),
None
);
assert_eq!(
app_strategy.runtime_dir(),
None
);Implementations§
Source§impl Apple
impl Apple
Sourcepub fn new(args: AppStrategyArgs) -> Result<Self, HomeDirError>
pub fn new(args: AppStrategyArgs) -> Result<Self, HomeDirError>
Create a new Apple AppStrategy
Trait Implementations§
Source§impl AppStrategy for Apple
impl AppStrategy for Apple
Source§fn config_dir(&self) -> PathBuf
fn config_dir(&self) -> PathBuf
Gets the configuration directory for your application.
Source§fn runtime_dir(&self) -> Option<PathBuf>
fn runtime_dir(&self) -> Option<PathBuf>
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 Apple
impl Ord for Apple
Source§impl PartialOrd for Apple
impl PartialOrd for Apple
impl Eq for Apple
impl StructuralPartialEq for Apple
Auto Trait Implementations§
impl Freeze for Apple
impl RefUnwindSafe for Apple
impl Send for Apple
impl Sync for Apple
impl Unpin for Apple
impl UnwindSafe for Apple
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