pub enum UserDir {
Desktop,
Documents,
Download,
Music,
Pictures,
Videos,
Templates,
PublicShare,
}Expand description
One of the user’s well-known content directories (Documents, Downloads, …).
On Linux and other Unix these follow xdg-user-dirs: $XDG_<NAME>_DIR when
set, non-empty and absolute, else the entry in
$XDG_CONFIG_HOME/user-dirs.dirs, which is where a localized desktop
records ~/Dokumente instead of ~/Documents. An entry pointing at $HOME
itself means the directory is disabled and resolves to None, as does a
missing entry. macOS and Windows use their conventional folders below the
home directory.
Variants§
Implementations§
Source§impl UserDir
impl UserDir
pub const fn env_var(self) -> &'static str
Sourcepub const fn conventional_name(self) -> &'static str
pub const fn conventional_name(self) -> &'static str
The folder name the platform conventionally uses below the home directory (English, not localized). macOS and Windows resolve to it; on XDG platforms it is only a hint for callers that need a default.
pub fn resolve(self) -> Option<PathBuf>
Sourcepub fn from_environment(self) -> Option<PathBuf>
pub fn from_environment(self) -> Option<PathBuf>
The directory the environment alone names: $XDG_<NAME>_DIR when set,
non-empty and absolute. Reads no user-dirs.dirs, so a caller that
must not read files (an app’s startup) can still honour the variable.