pub struct MediaDirs {
pub(crate) desktop: Option<PathBuf>,
pub(crate) documents: Option<PathBuf>,
pub(crate) downloads: Option<PathBuf>,
pub(crate) music: Option<PathBuf>,
pub(crate) pictures: Option<PathBuf>,
pub(crate) videos: Option<PathBuf>,
pub(crate) extra: ExtraMediaDirs,
}fs_media_dirs)Expand description
Common user directory paths used for user-specific media files.
It is not required that the media directories are accessible by the current user, nor that there is a directory at that path. A robust application should handle the case where media 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 media directory.
§Platform-specific behavior
As the filesystem conventions for discovering directories varies between
operating systems, constructors for MediaDirs that use the host platform’s
conventions are provided as extension traits under the std::os module.
Fields§
§desktop: Option<PathBuf>fs_media_dirs)documents: Option<PathBuf>fs_media_dirs)downloads: Option<PathBuf>fs_media_dirs)music: Option<PathBuf>fs_media_dirs)pictures: Option<PathBuf>fs_media_dirs)videos: Option<PathBuf>fs_media_dirs)extra: ExtraMediaDirsfs_media_dirs)Implementations§
Source§impl MediaDirs
impl MediaDirs
Sourcepub fn empty() -> MediaDirs
🔬This is a nightly-only experimental API. (fs_media_dirs)
pub fn empty() -> MediaDirs
fs_media_dirs)Create a known user directory set with no known directories.
This is useful with the builder set_* methods to create a MediaDirs
with exactly the directories you want, without any other defaults.
Sourcepub fn desktop(&self) -> Option<&Path>
🔬This is a nightly-only experimental API. (fs_media_dirs)
pub fn desktop(&self) -> Option<&Path>
fs_media_dirs)The OS-recognized user “Desktop” directory, often the Desktop
folder in the user’s home directory.
As a media directory, this should typically be used as a default path for file selection dialogs, not for automatically accessed file paths.
§Platform-specific behavior
When constructed using platform-specific conventions, the value is:
| OS | Path |
|---|---|
| XDG (Linux) | xdg-user-dir DESKTOP ($HOME/Desktop) |
| Darwin (macOS) | NSDesktopDirectory ($HOME/Desktop) |
| Windows | {FOLDERID_Desktop} (%USERPROFILE%\Desktop) |
Other paths can be configured via set_desktop.
Sourcepub fn documents(&self) -> Option<&Path>
🔬This is a nightly-only experimental API. (fs_media_dirs)
pub fn documents(&self) -> Option<&Path>
fs_media_dirs)The OS-recognized user “Documents” directory, often the Documents
folder in the user’s home directory.
As a media directory, this should typically be used as a default path for file selection dialogs, not for automatically accessed file paths.
§Platform-specific behavior
When constructed using platform-specific conventions, the value is:
| OS | Path |
|---|---|
| XDG (Linux) | xdg-user-dir DOCUMENTS ($HOME/Documents) |
| Darwin (macOS) | NSDocumentDirectory ($HOME/Documents) |
| Windows | {FOLDERID_Documents} (%USERPROFILE%\Documents) |
Other paths can be configured via set_documents.
Sourcepub fn downloads(&self) -> Option<&Path>
🔬This is a nightly-only experimental API. (fs_media_dirs)
pub fn downloads(&self) -> Option<&Path>
fs_media_dirs)The OS-recognized user “Downloads” directory, often the Downloads
folder in the user’s home directory.
As a media directory, this should typically be used as a default path for file selection dialogs, not for automatically accessed file paths.
§Platform-specific behavior
When constructed using platform-specific conventions, the value is:
| OS | Path |
|---|---|
| XDG (Linux) | xdg-user-dir DOWNLOAD ($HOME/Downloads) |
| Darwin (macOS) | NSDownloadsDirectory ($HOME/Downloads) |
| Windows | {FOLDERID_Downloads} (%USERPROFILE%\Downloads) |
Other paths can be configured via set_downloads.
Sourcepub fn music(&self) -> Option<&Path>
🔬This is a nightly-only experimental API. (fs_media_dirs)
pub fn music(&self) -> Option<&Path>
fs_media_dirs)The OS-recognized user “Music” directory, often the Music
folder in the user’s home directory.
As a media directory, this should typically be used as a default path for file selection dialogs, not for automatically accessed file paths.
§Platform-specific behavior
When constructed using platform-specific conventions, the value is:
| OS | Path |
|---|---|
| XDG (Linux) | xdg-user-dir MUSIC ($HOME/Music) |
| Darwin (macOS) | NSMusicDirectory ($HOME/Music) |
| Windows | {FOLDERID_Music} (%USERPROFILE%\Music) |
Other paths can be configured via set_music.
Sourcepub fn pictures(&self) -> Option<&Path>
🔬This is a nightly-only experimental API. (fs_media_dirs)
pub fn pictures(&self) -> Option<&Path>
fs_media_dirs)The OS-recognized user “Pictures” directory, often the Pictures
folder in the user’s home directory.
As a media directory, this should typically be used as a default path for file selection dialogs, not for automatically accessed file paths.
§Platform-specific behavior
When constructed using platform-specific conventions, the value is:
| OS | Path |
|---|---|
| XDG (Linux) | xdg-user-dir PICTURES ($HOME/Pictures) |
| Darwin (macOS) | NSPicturesDirectory ($HOME/Pictures) |
| Windows | {FOLDERID_Pictures} (%USERPROFILE%\Pictures) |
Other paths can be configured via set_pictures.
Sourcepub fn videos(&self) -> Option<&Path>
🔬This is a nightly-only experimental API. (fs_media_dirs)
pub fn videos(&self) -> Option<&Path>
fs_media_dirs)The OS-recognized user “Videos” directory, often the Videos
folder in the user’s home directory.
As a media directory, this should typically be used as a default path for file selection dialogs, not for automatically accessed file paths.
§Platform-specific behavior
When constructed using platform-specific conventions, the value is:
| OS | Path |
|---|---|
| XDG (Linux) | xdg-user-dir VIDEOS ($HOME/Videos) |
| Darwin (macOS) | NSMoviesDirectory ($HOME/Movies) |
| Windows | {FOLDERID_Videos} (%USERPROFILE%\Videos) |
Other paths can be configured via set_videos.
Source§impl MediaDirs
impl MediaDirs
Sourcepub fn set_desktop(&mut self, path: PathBuf) -> &mut MediaDirs
🔬This is a nightly-only experimental API. (fs_media_dirs)
pub fn set_desktop(&mut self, path: PathBuf) -> &mut MediaDirs
fs_media_dirs)Sourcepub fn set_documents(&mut self, path: PathBuf) -> &mut MediaDirs
🔬This is a nightly-only experimental API. (fs_media_dirs)
pub fn set_documents(&mut self, path: PathBuf) -> &mut MediaDirs
fs_media_dirs)Sourcepub fn set_downloads(&mut self, path: PathBuf) -> &mut MediaDirs
🔬This is a nightly-only experimental API. (fs_media_dirs)
pub fn set_downloads(&mut self, path: PathBuf) -> &mut MediaDirs
fs_media_dirs)Sourcepub fn set_music(&mut self, path: PathBuf) -> &mut MediaDirs
🔬This is a nightly-only experimental API. (fs_media_dirs)
pub fn set_music(&mut self, path: PathBuf) -> &mut MediaDirs
fs_media_dirs)Sourcepub fn set_pictures(&mut self, path: PathBuf) -> &mut MediaDirs
🔬This is a nightly-only experimental API. (fs_media_dirs)
pub fn set_pictures(&mut self, path: PathBuf) -> &mut MediaDirs
fs_media_dirs)Sourcepub fn set_videos(&mut self, path: PathBuf) -> &mut MediaDirs
🔬This is a nightly-only experimental API. (fs_media_dirs)
pub fn set_videos(&mut self, path: PathBuf) -> &mut MediaDirs
fs_media_dirs)Trait Implementations§
Source§impl MediaDirsExt for MediaDirs
impl MediaDirsExt for MediaDirs
Source§fn xdg() -> Result<MediaDirs, Error>
fn xdg() -> Result<MediaDirs, Error>
fs_media_dirs)Source§fn templates(&self) -> Option<&Path>
fn templates(&self) -> Option<&Path>
fs_media_dirs)Templates
folder in the user’s home directory. Read moreSource§fn set_templates(&mut self, path: PathBuf) -> &mut MediaDirs
fn set_templates(&mut self, path: PathBuf) -> &mut MediaDirs
fs_media_dirs)Auto Trait Implementations§
impl Freeze for MediaDirs
impl RefUnwindSafe for MediaDirs
impl Send for MediaDirs
impl Sync for MediaDirs
impl Unpin for MediaDirs
impl UnsafeUnpin for MediaDirs
impl UnwindSafe for MediaDirs
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.