pub struct PathResolver {
pub qualifier: &'static str,
pub organization: &'static str,
pub application: &'static str,
pub cache_env_vars: &'static [&'static str],
pub data_env_vars: &'static [&'static str],
}Expand description
Static configuration for application path resolution.
Fields§
§qualifier: &'static strThe qualifier for ProjectDirs.
organization: &'static strThe organization for ProjectDirs.
application: &'static strThe application for ProjectDirs.
cache_env_vars: &'static [&'static str]The resolution order for cache directories environment variables.
data_env_vars: &'static [&'static str]The resolution order for data directories environment variables.
Implementations§
Source§impl PathResolver
impl PathResolver
Sourcepub fn project_dirs(&self) -> Option<ProjectDirs>
pub fn project_dirs(&self) -> Option<ProjectDirs>
Get the ProjectDirs for this config.
Sourcepub fn resolve_cache_dir<P: AsRef<Path>>(
&self,
path: Option<P>,
) -> Option<PathBuf>
pub fn resolve_cache_dir<P: AsRef<Path>>( &self, path: Option<P>, ) -> Option<PathBuf>
Resolve the cache directory for this config.
Resolution Order:
path, if present.env[$VAR]for eachself.cache_env_vars; in order.self.project_dirs().cache_dir(), if present.None
§Project Dirs Behavior
| Platform | Value | Example |
|---|---|---|
| Linux | $XDG_CACHE_HOME/_project_path_ or $HOME/.cache/_project_path_ | /home/alice/.cache/barapp |
| macOS | $HOME/Library/Caches/_project_path_ | /Users/Alice/Library/Caches/com.Foo-Corp.Bar-App |
| Windows | {FOLDERID_LocalAppData}\_project_path_\cache | C:\Users\Alice\AppData\Local\Foo Corp\Bar App\cache |
Sourcepub fn resolve_data_dir<P: AsRef<Path>>(
&self,
path: Option<P>,
) -> Option<PathBuf>
pub fn resolve_data_dir<P: AsRef<Path>>( &self, path: Option<P>, ) -> Option<PathBuf>
Resolve the data directory for this config.
Resolution Order:
path, if present.env[$VAR]for eachself.data_env_vars; in order.self.project_dirs().data_dirs(), if present.None
§Project Dirs Behavior
| Platform | Value | Example |
|---|---|---|
| Linux | $XDG_DATA_HOME/_project_path_ or $HOME/.local/share/_project_path_ | /home/alice/.local/share/barapp |
| macOS | $HOME/Library/Application Support/_project_path_ | /Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App |
| Windows | {FOLDERID_LocalAppData}\_project_path_\data | C:\Users\Alice\AppData\Local\Foo Corp\Bar App\data |
Auto Trait Implementations§
impl Freeze for PathResolver
impl RefUnwindSafe for PathResolver
impl Send for PathResolver
impl Sync for PathResolver
impl Unpin for PathResolver
impl UnwindSafe for PathResolver
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