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 #162083)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 #162083)documents: Option<PathBuf>fs_media_dirs #162083)downloads: Option<PathBuf>fs_media_dirs #162083)music: Option<PathBuf>fs_media_dirs #162083)pictures: Option<PathBuf>fs_media_dirs #162083)videos: Option<PathBuf>fs_media_dirs #162083)extra: ExtraMediaDirsfs_media_dirs #162083)Implementations§
Source§impl MediaDirs
impl MediaDirs
Sourcepub fn empty() -> Self
🔬This is a nightly-only experimental API. (fs_media_dirs #162083)
pub fn empty() -> Self
fs_media_dirs #162083)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 #162083)
pub fn desktop(&self) -> Option<&Path>
fs_media_dirs #162083)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 #162083)
pub fn documents(&self) -> Option<&Path>
fs_media_dirs #162083)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 #162083)
pub fn downloads(&self) -> Option<&Path>
fs_media_dirs #162083)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 #162083)
pub fn music(&self) -> Option<&Path>
fs_media_dirs #162083)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 #162083)
pub fn pictures(&self) -> Option<&Path>
fs_media_dirs #162083)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 #162083)
pub fn videos(&self) -> Option<&Path>
fs_media_dirs #162083)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 Self
🔬This is a nightly-only experimental API. (fs_media_dirs #162083)
pub fn set_desktop(&mut self, path: PathBuf) -> &mut Self
fs_media_dirs #162083)Sourcepub fn set_documents(&mut self, path: PathBuf) -> &mut Self
🔬This is a nightly-only experimental API. (fs_media_dirs #162083)
pub fn set_documents(&mut self, path: PathBuf) -> &mut Self
fs_media_dirs #162083)Sourcepub fn set_downloads(&mut self, path: PathBuf) -> &mut Self
🔬This is a nightly-only experimental API. (fs_media_dirs #162083)
pub fn set_downloads(&mut self, path: PathBuf) -> &mut Self
fs_media_dirs #162083)Sourcepub fn set_music(&mut self, path: PathBuf) -> &mut Self
🔬This is a nightly-only experimental API. (fs_media_dirs #162083)
pub fn set_music(&mut self, path: PathBuf) -> &mut Self
fs_media_dirs #162083)Sourcepub fn set_pictures(&mut self, path: PathBuf) -> &mut Self
🔬This is a nightly-only experimental API. (fs_media_dirs #162083)
pub fn set_pictures(&mut self, path: PathBuf) -> &mut Self
fs_media_dirs #162083)Sourcepub fn set_videos(&mut self, path: PathBuf) -> &mut Self
🔬This is a nightly-only experimental API. (fs_media_dirs #162083)
pub fn set_videos(&mut self, path: PathBuf) -> &mut Self
fs_media_dirs #162083)Trait Implementations§
Source§impl MediaDirsExt for MediaDirs
impl MediaDirsExt for MediaDirs
Source§fn xdg() -> Result<Self>
fn xdg() -> Result<Self>
fs_media_dirs #162083)Source§fn templates(&self) -> Option<&Path>
fn templates(&self) -> Option<&Path>
fs_media_dirs #162083)Templates
folder in the user’s home directory. Read moreSource§fn set_templates(&mut self, path: PathBuf) -> &mut Self
fn set_templates(&mut self, path: PathBuf) -> &mut Self
fs_media_dirs #162083)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<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type #102070)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read more