Skip to main content

Crate folders

Crate folders 

Source
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

§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 None when it is not defined on the platform.
documents
Returns the user’s documents directory, or None when it is not defined on the platform.
downloads
Returns the user’s downloads directory, or None when it is not defined on the platform.
executable
Returns the directory for user-specific executables, or None when 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 None when it is not defined on the platform.
pictures
Returns the user’s pictures directory, or None when it is not defined on the platform.
projects
Returns the user’s projects directory, or None when it is not defined on the platform.
public
Returns the user’s public share directory, or None when it is not defined on the platform.
runtime
Returns the runtime directory for the user, or None when 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 None when it is not defined on the platform.
videos
Returns the user’s videos directory, or None when it is not defined on the platform.

Type Aliases§

Result
Result alias for fallible base-directory resolution.