Etcetera
An unopinionated Rust library for locating configuration, data and cache directories across platforms
Install / Use
/learn @lunacookies/EtceteraREADME
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.
MSRV: 1.87.0
Note: The MSRV was raised to 1.87.0 in v0.11 to remove the dependency on the home crate & instead use the undeprecated std::env::home_dir.
If you want, you can use v0.9 with an MSRV of 1.70.0 or v0.10 with an MSRV of 1.81.0 instead.
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.acme-corp.Frobnicator-Plus - Windows:
~\AppData\Roaming\Acme Corp\Frobnicator Plus
- XDG:
Note: the location of the home (~) is determined by std::env::home_dir.
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: UsesWindowson Windows &XDGeverywhere else. This is used by most CLI tools & some GUI tools on each platform.base_strategy::choose_native_strategy&app_strategy::choose_native_strategy: UsesWindowson Windows,Appleon macOS/iOS, &XDGeverywhere else. This is used by most GUI applications on each platform.
See the documentation for examples.
Related Skills
node-connect
341.6kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.6kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.6kCommit, push, and open a PR
