Skip to main content

HomeDirs

Struct HomeDirs 

Source
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,
}
๐Ÿ”ฌThis is a nightly-only experimental API. (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>
๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)
ยงconfig: Option<PathBuf>
๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)
ยงdata: Option<PathBuf>
๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)
ยงstate: Option<PathBuf>
๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)
ยงextra: ExtraHomeDirs
๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)

Implementationsยง

Sourceยง

impl HomeDirs

Source

pub fn empty() -> HomeDirs

๐Ÿ”ฌThis is a nightly-only experimental API. (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.

Source

pub fn cache_home(&self) -> Option<&Path>

๐Ÿ”ฌThis is a nightly-only experimental API. (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:

OSPath
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.

Source

pub fn config_home(&self) -> Option<&Path>

๐Ÿ”ฌThis is a nightly-only experimental API. (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:

OSPath
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.

Source

pub fn data_home(&self) -> Option<&Path>

๐Ÿ”ฌThis is a nightly-only experimental API. (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:

OSPath
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.

Source

pub fn state_home(&self) -> Option<&Path>

๐Ÿ”ฌThis is a nightly-only experimental API. (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:

OSPath
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

Source

pub fn set_cache_home(&mut self, path: PathBuf) -> &mut HomeDirs

๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)

Set the path for Self::cache_home.

ยงPanics

Panics if the provided path is not absolute.

Source

pub fn set_config_home(&mut self, path: PathBuf) -> &mut HomeDirs

๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)

Set the path for Self::config_home.

ยงPanics

Panics if the provided path is not absolute.

Source

pub fn set_data_home(&mut self, path: PathBuf) -> &mut HomeDirs

๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)

Set the path for Self::data_home.

ยงPanics

Panics if the provided path is not absolute.

Source

pub fn set_state_home(&mut self, path: PathBuf) -> &mut HomeDirs

๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)

Set the path for Self::state_home.

ยงPanics

Panics if the provided path is not absolute.

Trait Implementationsยง

Sourceยง

impl Clone for HomeDirs

Sourceยง

fn clone(&self) -> HomeDirs

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Sourceยง

impl Debug for HomeDirs

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Sourceยง

impl HomeDirsExt for HomeDirs

Sourceยง

fn xdg() -> Result<HomeDirs, Error>

๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)
Load the user directory paths according to the XDG Base Directory Specification. Read more
Sourceยง

fn runtime_home(&self) -> Option<&Path>

๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)
A base directory relative to which user-specific runtime files (such as sockets, named pipes, etc) should be stored. Read more
Sourceยง

fn config_dirs(&self) -> Option<XdgDirs<'_>>

๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)
A preference-ordered list of base directories to search for config files in addition to config_home. Read more
Sourceยง

fn data_dirs(&self) -> Option<XdgDirs<'_>>

๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)
A preference-ordered list of base directories to search for data files in addition to data_home. Read more
Sourceยง

fn set_runtime_home(&mut self, path: PathBuf) -> &mut HomeDirs

๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)
Set the path for Self::runtime_home. Read more
Sourceยง

fn set_config_dirs(&mut self, paths: OsString) -> &mut HomeDirs

๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)
Set the paths for Self::config_dirs. Read more
Sourceยง

fn set_data_dirs(&mut self, paths: OsString) -> &mut HomeDirs

๐Ÿ”ฌThis is a nightly-only experimental API. (fs_home_dirs)
Set the paths for Self::data_dirs. Read more

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Sourceยง

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Sourceยง

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Sourceยง

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Sourceยง

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Sourceยง

impl<T> CloneToUninit for T
where T: Clone,

Sourceยง

unsafe fn clone_to_uninit(&self, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<T> Conv for T

Sourceยง

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Sourceยง

impl<T> Downcast for T
where T: Any,

Sourceยง

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Sourceยง

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Sourceยง

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Sourceยง

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Sourceยง

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> โ“˜

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Sourceยง

impl<T> DynClone for T
where T: Clone,

Sourceยง

impl<T> FmtForward for T

Sourceยง

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Sourceยง

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Sourceยง

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Sourceยง

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Sourceยง

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Sourceยง

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Sourceยง

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Sourceยง

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Sourceยง

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T> Instrument for T

Sourceยง

fn instrument(self, span: Span) -> Instrumented<Self> โ“˜

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Sourceยง

fn in_current_span(self) -> Instrumented<Self> โ“˜

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

impl<T> IntoEither for T

Sourceยง

fn into_either(self, into_left: bool) -> Either<Self, Self> โ“˜

Converts 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 more
Sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ“˜
where F: FnOnce(&Self) -> bool,

Converts 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 more
Sourceยง

impl<T> Pipe for T
where T: ?Sized,

Sourceยง

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Sourceยง

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Sourceยง

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Sourceยง

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Sourceยง

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Sourceยง

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows 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
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows 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
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Sourceยง

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Sourceยง

impl<T> PossiblyOption<T> for T

Sourceยง

fn to_option(self) -> Option<T>

Convert this object into an Option<T>
Sourceยง

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Sourceยง

impl<T> Same for T

Sourceยง

type Output = T

Should always be Self
Sourceยง

impl<T> Tap for T

Sourceยง

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Sourceยง

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Sourceยง

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Sourceยง

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Sourceยง

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Sourceยง

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Sourceยง

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Sourceยง

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Sourceยง

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Sourceยง

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Sourceยง

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .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
where Self: BorrowMut<B>, B: ?Sized,

Calls .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
where Self: AsRef<R>, R: ?Sized,

Calls .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
where Self: AsMut<R>, R: ?Sized,

Calls .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
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Sourceยง

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Sourceยง

impl<T> ToOwned for T
where T: Clone,

Sourceยง

type Owned = T

The resulting type after obtaining ownership.
Sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Sourceยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Sourceยง

impl<T> TryConv for T

Sourceยง

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = !

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Sourceยง

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Sourceยง

fn vzip(self) -> V

Sourceยง

impl<T> WithSubscriber for T

Sourceยง

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> โ“˜
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

fn with_current_subscriber(self) -> WithDispatch<Self> โ“˜

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more