pub struct HomeDirs {
pub(crate) cache: Option<PathBuf>,
pub(crate) config: Option<PathBuf>,
pub(crate) data: Option<PathBuf>,
pub(crate) state: Option<PathBuf>,
pub(crate) extra: ExtraHomeDirs,
}fs_home_dirs)Expand description
Common user directory paths used for user-specific application files.
It is not required that the user directories are accessible by the current user, nor that there is a directory at that path. A robust application should handle the case where user directories are incorrectly configured.
Even when configured correctly, multiple paths may point to the same location. You should not assume that a file written relative to one directory will not conflict with the same relative path in a different home directory.
ยงPlatform-specific behavior
As the filesystem conventions for discovering directories varies between
operating systems, constructors for HomeDirs that use the host platformโs
conventions are provided as extension traits under the std::os module.
Fieldsยง
ยงcache: Option<PathBuf>fs_home_dirs)config: Option<PathBuf>fs_home_dirs)data: Option<PathBuf>fs_home_dirs)state: Option<PathBuf>fs_home_dirs)extra: ExtraHomeDirsfs_home_dirs)Implementationsยง
Sourceยงimpl HomeDirs
impl HomeDirs
Sourcepub fn empty() -> HomeDirs
๐ฌThis is a nightly-only experimental API. (fs_home_dirs)
pub fn empty() -> HomeDirs
fs_home_dirs)Create a known user directory set with no known directories.
This is useful with the builder set_* methods to create a HomeDirs
with exactly the directories you want, without any other defaults.
Sourcepub fn cache_home(&self) -> Option<&Path>
๐ฌThis is a nightly-only experimental API. (fs_home_dirs)
pub fn cache_home(&self) -> Option<&Path>
fs_home_dirs)A base directory relative to which user-specific non-essential cache data files should be stored.
โCacheโ files are temporary data that can be used to cache redundant work of an application, but which can be discarded arbitrarily and recreated as necessary. Files in this directory may potentially be automatically purged any time they are not currently open, or they may not, depending on system configuration. A robust application should ensure that its caches do not grow without a reasonable bound.
This is the same directory for all applications. Applications should use a subdirectory for application-specific cache files.
ยงPlatform-specific behavior
When constructed using platform-specific conventions, the value is:
| OS | Path |
|---|---|
| XDG (Linux) | ${XDG_CACHE_HOME:-$HOME/.cache} |
| Darwin (macOS) | NSCachesDirectory ($HOME/Library/Caches) |
| Windows | {FOLDERID_LocalAppData} (%LOCALAPPDATA%) |
Other paths can be configured via set_cache_home.
Sourcepub fn config_home(&self) -> Option<&Path>
๐ฌThis is a nightly-only experimental API. (fs_home_dirs)
pub fn config_home(&self) -> Option<&Path>
fs_home_dirs)A base directory relative to which user-specific configuration files should be stored.
โConfigโ files are configuration managed by the user, either by editing the files directly or through a managing application. Configuration is generally expected to be meaningful to the user and portable enough to back up and synchronize across the same userโs account on multiple systems.
This is the same directory for all applications. Applications should use a subdirectory for application-specific configuration files.
ยงPlatform-specific behavior
When constructed using platform-specific conventions, the value is:
| OS | Path |
|---|---|
| XDG (Linux) | ${XDG_CONFIG_HOME:-$HOME/.config} |
| Darwin (macOS) | NSApplicationSupportDirectory ($HOME/Library/Application Support) |
| Windows | {FOLDERID_RoamingAppData} (%APPDATA%) |
Other paths can be configured via set_config_home.
Sourcepub fn data_home(&self) -> Option<&Path>
๐ฌThis is a nightly-only experimental API. (fs_home_dirs)
pub fn data_home(&self) -> Option<&Path>
fs_home_dirs)A base directory relative to which user-specific data files should be stored.
โDataโ files are application-specific data that is meaningful to the user in some way and does not implicitly rely on system configuration or details of how the application is installed otherwise irrelevant to the user. As such, data makes sense to back up and synchronize between the same userโs account on multiple systems. If a file is specific to a single machine, itโs probably state.
This is the same directory for all applications. Applications should use a subdirectory for application-specific data files.
ยงPlatform-specific behavior
When constructed using platform-specific conventions, the value is:
| OS | Path |
|---|---|
| XDG (Linux) | ${XDG_DATA_HOME:-$HOME/.local/share} |
| Darwin (macOS) | NSApplicationSupportDirectory ($HOME/Library/Application Support) |
| Windows | {FOLDERID_RoamingAppData} (%APPDATA%) |
Other paths can be configured via set_data_home.
Sourcepub fn state_home(&self) -> Option<&Path>
๐ฌThis is a nightly-only experimental API. (fs_home_dirs)
pub fn state_home(&self) -> Option<&Path>
fs_home_dirs)A base directory relative to which user-specific state files should be stored.
โStateโ files are data that should persist between application restarts, but which is not important nor portable enough to the user to synchronize between multiple systems like data are. Common examples include history (such as logs, recently used files, etc) and any current state of the application that should be reused (such as view, layout, open files, undo history, etc).
This is the same directory for all applications. Applications should use a subdirectory for application-specific state files.
ยงPlatform-specific behavior
When constructed using platform-specific conventions, the value is:
| OS | Path |
|---|---|
| XDG (Linux) | ${XDG_STATE_HOME:-$HOME/.local/state} |
| Darwin (macOS) | NSApplicationSupportDirectory ($HOME/Library/Application Support) |
| Windows | {FOLDERID_LocalAppData} (%LOCALAPPDATA%) |
Other paths can be configured via set_state_home.
Sourceยงimpl HomeDirs
impl HomeDirs
Sourcepub fn set_cache_home(&mut self, path: PathBuf) -> &mut HomeDirs
๐ฌThis is a nightly-only experimental API. (fs_home_dirs)
pub fn set_cache_home(&mut self, path: PathBuf) -> &mut HomeDirs
fs_home_dirs)Sourcepub fn set_config_home(&mut self, path: PathBuf) -> &mut HomeDirs
๐ฌThis is a nightly-only experimental API. (fs_home_dirs)
pub fn set_config_home(&mut self, path: PathBuf) -> &mut HomeDirs
fs_home_dirs)Sourcepub fn set_data_home(&mut self, path: PathBuf) -> &mut HomeDirs
๐ฌThis is a nightly-only experimental API. (fs_home_dirs)
pub fn set_data_home(&mut self, path: PathBuf) -> &mut HomeDirs
fs_home_dirs)Sourcepub fn set_state_home(&mut self, path: PathBuf) -> &mut HomeDirs
๐ฌThis is a nightly-only experimental API. (fs_home_dirs)
pub fn set_state_home(&mut self, path: PathBuf) -> &mut HomeDirs
fs_home_dirs)Trait Implementationsยง
Sourceยงimpl HomeDirsExt for HomeDirs
impl HomeDirsExt for HomeDirs
Sourceยงfn xdg() -> Result<HomeDirs, Error>
fn xdg() -> Result<HomeDirs, Error>
fs_home_dirs)Sourceยงfn runtime_home(&self) -> Option<&Path>
fn runtime_home(&self) -> Option<&Path>
fs_home_dirs)Sourceยงfn config_dirs(&self) -> Option<XdgDirs<'_>>
fn config_dirs(&self) -> Option<XdgDirs<'_>>
fs_home_dirs)config_home. Read moreSourceยงfn data_dirs(&self) -> Option<XdgDirs<'_>>
fn data_dirs(&self) -> Option<XdgDirs<'_>>
fs_home_dirs)Sourceยงfn set_runtime_home(&mut self, path: PathBuf) -> &mut HomeDirs
fn set_runtime_home(&mut self, path: PathBuf) -> &mut HomeDirs
fs_home_dirs)Sourceยงfn set_config_dirs(&mut self, paths: OsString) -> &mut HomeDirs
fn set_config_dirs(&mut self, paths: OsString) -> &mut HomeDirs
fs_home_dirs)Sourceยงfn set_data_dirs(&mut self, paths: OsString) -> &mut HomeDirs
fn set_data_dirs(&mut self, paths: OsString) -> &mut HomeDirs
fs_home_dirs)Auto Trait Implementationsยง
impl Freeze for HomeDirs
impl RefUnwindSafe for HomeDirs
impl Send for HomeDirs
impl Sync for HomeDirs
impl Unpin for HomeDirs
impl UnsafeUnpin for HomeDirs
impl UnwindSafe for HomeDirs
Blanket Implementationsยง
Sourceยงimpl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Sourceยงimpl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Sourceยงfn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Sourceยงfn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Sourceยงfn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Anyโs vtable from &Traitโs.Sourceยงfn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Anyโs vtable from &mut Traitโs.Sourceยงimpl<T> DowncastSend for T
impl<T> DowncastSend for T
Sourceยงimpl<T> DowncastSync for T
impl<T> DowncastSync for T
Sourceยงimpl<T> FmtForward for T
impl<T> FmtForward for T
Sourceยงfn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Sourceยงfn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Sourceยงfn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Sourceยงfn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Sourceยงfn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Sourceยงfn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Sourceยงfn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Sourceยงfn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self> โ
fn instrument(self, span: Span) -> Instrumented<Self> โ
Sourceยงfn in_current_span(self) -> Instrumented<Self> โ
fn in_current_span(self) -> Instrumented<Self> โ
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self> โ
fn into_either(self, into_left: bool) -> Either<Self, Self> โ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงimpl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Sourceยงfn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Sourceยงfn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSourceยงfn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSourceยงfn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Sourceยงfn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Sourceยงfn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Sourceยงfn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Sourceยงfn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Sourceยงimpl<T> PossiblyOption<T> for T
impl<T> PossiblyOption<T> for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Sourceยงimpl<T> Tap for T
impl<T> Tap for T
Sourceยงfn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSourceยงfn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSourceยงfn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSourceยงfn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSourceยงfn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSourceยงfn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSourceยงfn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Sourceยงfn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Sourceยงfn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Sourceยงfn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Sourceยงfn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Sourceยงfn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Sourceยงfn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.