#xdg-base #directory #path #config-directory #xdg #dirs

etcetera

An unopinionated library for obtaining configuration, data, cache, & other directories

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

Download history 156750/week @ 2024-07-27 152424/week @ 2024-08-03 183436/week @ 2024-08-10 200059/week @ 2024-08-17 198476/week @ 2024-08-24 186262/week @ 2024-08-31 222672/week @ 2024-09-07 191238/week @ 2024-09-14 222927/week @ 2024-09-21 215063/week @ 2024-09-28 264526/week @ 2024-10-05 240032/week @ 2024-10-12 279601/week @ 2024-10-19 291945/week @ 2024-10-26 283134/week @ 2024-11-02 233613/week @ 2024-11-09

1,130,427 downloads per month
Used in 677 crates (46 directly)

MIT/Apache

50KB
445 lines

crates.io version crates.io revdeps documentation license

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:

Strategies

Etcetera has 2 modes of operation: BaseStrategy & AppStrategy:

  • With BaseStrategy, you just get the location of the respective directory. For eg. for config_dir():
    • XDG: ~/.config
    • Apple: ~/Library/Preferences
    • Windows: ~\AppData\Roaming
  • 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

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: Uses Windows 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: Uses Windows on Windows, Apple on macOS/iOS, & XDG everywhere else. This is used by most GUI applications on each platform.

See the documentation for examples.

Dependencies

~0–7.5MB
~59K SLoC