Crate xdg_user_macros

Source
Expand description

xdg-macros provides macros to aid developers with properly adhearing to the XDG standard in user-targeted applications.

This package uses std::env as the primary form of defining the folder strucutre, but falls back to the common locations since some OS implementations do not set the environment variables and instead rely upon the user to specify them according to the standard.

Example:

let path = xdg_data_home!("my-awesome-app");
let mut expected = home_dir().unwrap();
expected.push(".local/share/my-awesome-app");
assert_eq!(path, expected)

NOTE: The macros provided in this library do not create the folders associated with the returned PathBuf from each macro. Folder presence checks should be handled elsewhere in the application.

Macrosยง

  • Returns a PathBuf pointing to what should be defined as the $XDG_CACHE_HOME environment variable.
  • Returns a PathBuf pointing to what should be defined as the $XDG_CONFIG_HOME environment variable.
  • Returns a PathBuf pointing to what should be defined as the $XDG_DATA_HOME environment variable.
  • Returns a PathBuf pointing to what should be defined as the $XDG_RUNTIME_DIR environment variable.