Crates.io | etcetera |
lib.rs | etcetera |
version | 0.8.0 |
source | src |
created_at | 2020-05-16 14:28:08.018938 |
updated_at | 2023-04-26 15:27:41.395579 |
description | An unopinionated library for obtaining configuration, data, cache, & other directories |
homepage | https://github.com/lunacookies/etcetera |
repository | https://github.com/lunacookies/etcetera |
max_upload_size | |
id | 242382 |
size | 61,371 |
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.
Etcetera supports the following conventions:
~/.myapp
Etcetera has 2 modes of operation: BaseStrategy
& AppStrategy
:
BaseStrategy
, you just get the location of the respective directory. For eg. for config_dir()
:
~/.config
~/Library/Preferences
~\AppData\Roaming
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:
~/.config/frobnicator-plus
~/.frobnicator-plus
~/Library/Preferences/org.acmecorp.FrobnicatorPlus
~\AppData\Roaming\Acme Corp\Frobnicator Plus
Note: the location of the home (~) is determined by the home
crate.
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 for examples.