Skip to content

An unopinionated Rust library for locating configuration, data and cache directories across platforms

License

Notifications You must be signed in to change notification settings

kirawi/etcetera

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

MSRV: 1.54.0

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.

About

An unopinionated Rust library for locating configuration, data and cache directories across platforms

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%