12 releases (7 breaking)
0.8.0 | Apr 26, 2023 |
---|---|
0.6.0 | Apr 21, 2023 |
0.4.0 | May 9, 2022 |
0.3.2 | Nov 26, 2020 |
0.1.0 | May 16, 2020 |
#6 in Configuration
1,152,189 downloads per month
Used in 670 crates
(44 directly)
50KB
445 lines
Etcetera
This is a Rust library that allows you to determine the locations of configuration, data, cache & other files for your application. Existing Rust libraries generally do not give you a choice in terms of which standards/conventions they follow. Etcetera, on the other hand, gives you the choice.
Conventions
Etcetera supports the following conventions:
- the XDG base directory
- Apple's Standard Directories
- Window's Known Folder Locations
- the "Unix Single-folder Convention" i.e. everything in
~/.myapp
Strategies
Etcetera has 2 modes of operation: BaseStrategy
& AppStrategy
:
- With
BaseStrategy
, you just get the location of the respective directory. For eg. forconfig_dir()
:- XDG:
~/.config
- Apple:
~/Library/Preferences
- Windows:
~\AppData\Roaming
- XDG:
- With
AppStrategy
, you provide additional information to get the location of your app directory. For eg. if you provide the following details:{ top_level_domain: "org", author: "Acme Corp", app_name: "Frobnicator Plus" }
, you'll get:- XDG:
~/.config/frobnicator-plus
- Unix:
~/.frobnicator-plus
- Apple:
~/Library/Preferences/org.acmecorp.FrobnicatorPlus
- Windows:
~\AppData\Roaming\Acme Corp\Frobnicator Plus
- XDG:
Note: the location of the home (~) is determined by the home
crate.
Convenience functions
Etcetera also provides convenience functions for selecting the appropriate strategy on each platform:
base_strategy::choose_base_strategy
&app_strategy::choose_app_strategy
: UsesWindows
on Windows &XDG
everywhere else. This is used by most CLI tools & some GUI tools on each platform.base_strategy::choose_native_strategy
&app_strategy::choose_native_strategy
: UsesWindows
on Windows,Apple
on macOS/iOS, &XDG
everywhere else. This is used by most GUI applications on each platform.
See the for examples.
Dependencies
~0–12MB
~68K SLoC