Expand description
Resolves standard platform base directories (config, data, cache, state, executable, user dirs, home) with zero dependencies.
By default each function follows the native conventions of the host OS. Enabling the xdg
cargo feature forces XDG semantics on every platform.
§Function families
- Base dirs:
config,data,cache,state, plus their app-scoped_for(qualifier, org, app)variants (config_for,data_for,cache_for,state_for). - User dirs:
downloads,desktop,documents,music,pictures,videos,templates,public,projects. executableandhome.
§Return types
Functions for always-present directories return Result, erroring only when HOME cannot
be resolved. Functions whose directory may legitimately be absent return Option.
§Example
let cfg = folders::config_for("com", "example", "myapp")?;Enums§
- Error
- Reason a base directory could not be resolved.
Functions§
- cache
- Returns the user’s platform-native cache directory, resolving alternative paths if set through standard environment variables and system settings
- cache_
for - Returns the user’s platform-native cache directory with the derived application-specific path suffix, resolving alternative paths if set through standard environment variables and system settings. Per-platform the construction of the application-specific paths differ.
- config
- Returns the user’s platform-native configuration directory, resolving alternative paths if set through standard environment variables and system settings
- config_
for - Returns the user’s platform-native configuration directory with the derived application-specific path suffix, resolving alternative paths if set through standard environment variables and system settings. Per-platform the construction of the application-specific paths differ.
- data
- Returns the user’s platform-native data directory, resolving alternative paths if set through standard environment variables and system settings
- data_
for - Returns the user’s platform-native data directory with the derived application-specific path suffix, resolving alternative paths if set through standard environment variables and system settings. Per-platform the construction of the application-specific paths differ.
- desktop
- Returns the user’s desktop directory, or
Nonewhen it is not defined on the platform. - documents
- Returns the user’s documents directory, or
Nonewhen it is not defined on the platform. - downloads
- Returns the user’s downloads directory, or
Nonewhen it is not defined on the platform. - executable
- Returns the directory for user-specific executables, or
Nonewhen it is not configured on the platform. - home
- If set, returns the user’s home directory, resolved using the content of the $HOME environment variable on UNIX-based systems, or %USERPROFILE% on windows.
- music
- Returns the user’s music directory, or
Nonewhen it is not defined on the platform. - pictures
- Returns the user’s pictures directory, or
Nonewhen it is not defined on the platform. - projects
- Returns the user’s projects directory, or
Nonewhen it is not defined on the platform. - public
- Returns the user’s public share directory, or
Nonewhen it is not defined on the platform. - runtime
- Returns the runtime directory for the user, or
Nonewhen it is not configured on the platform. - state
- Returns the user’s platform-native state directory, resolving alternative paths if set through standard environment variables and system settings
- state_
for - Returns the user’s platform-native state directory with the derived application-specific path suffix, resolving alternative paths if set through standard environment variables and system settings. Per-platform the construction of the application-specific paths differ.
- templates
- Returns the user’s templates directory, or
Nonewhen it is not defined on the platform. - videos
- Returns the user’s videos directory, or
Nonewhen it is not defined on the platform.
Type Aliases§
- Result
- Result alias for fallible base-directory resolution.