Skip to main content

MediaDirsExt

Trait MediaDirsExt 

Source
pub trait MediaDirsExt: Sized {
    // Required method
    fn known_folders() -> Result<Self>;
}
ⓘ This trait cannot be implemented outside std.
🔬This is a nightly-only experimental API. (fs_media_dirs #162083)
Available on Windows only.
Expand description

Windows-specific extensions to fs::MediaDirs.

Required Methods§

Source

fn known_folders() -> Result<Self>

🔬This is a nightly-only experimental API. (fs_media_dirs #162083)

Load the known user folder paths using the Known Folders API.

The loaded known folders are:

MediaDirsKNOWNFOLDERID
desktopFOLDERID_Desktop (%USERPROFILE%\Desktop)
documentsFOLDERID_Documents (%USERPROFILE%\Documents)
downloadsFOLDERID_Downloads (%USERPROFILE%\Downloads)
musicFOLDERID_Music (%USERPROFILE%\Music)
picturesFOLDERID_Pictures (%USERPROFILE%\Pictures)
videosFOLDERID_Videos (%USERPROFILE%\Videos)
§Errors

Errors if the underlying system discovery API returns an error. The lack of a configured path is not considered an error and results in a None value.

§Implementation-specific behavior

Calls SHGetKnownFolderPath for the current user once for each known folder. Does not create the folder if missing.

COM should be initialized on the thread that calls this function or else it may return unexpected errors.

This behavior may change in the future. One example change that we explicitly reserve the right to make is to load additional common directories not currently in this list.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§