Crate cr_program_settings

Source
Expand description

cr_program_state is a library that simplifies saving a settings file for the program.

Modules§

prelude
Prelude module that contains all the imports for cr_program_settings;
settings_container
Source code for the settings container. SettingsContainer source file

Macros§

delete_settings
Deletes settings located at the home directory with a name matching the crate name Syntax: delete_settings!() // deletes file named: env!(“CARGO_CRATE_NAME”) file stored in the folder named: env!(“CARGO_CRATE_NAME”) delete_settings!(file_name) // deletes the file named: file_name stored in the folder named: env!(“CARGO_CRATE_NAME”) delete_settings!(file_name, folder_name) // deletes the file named: file_name stored in the folder named: folder_name
load_settings
Loads settings given a type to load, from the home directory with a name matching the crate name
save_settings
Saves settings given a struct to save, to the home directory with a name matching the crate name

Enums§

LoadSettingsError
Enum state representing the possible errors that can occur when loading settings
SaveSettingsError
An enum state representing the kinds of errors that saving settings has

Statics§

SETTINGS_PATHS
Global settings file path list, paths are added when successfully loaded, or when successfully saved.

Functions§

delete_setting_file
Deletes a specific settings file
delete_settings
Deletes the settings directory found in the <user home>/crate_name e.g. /home/username/my_cool_project
get_user_home
Returns the users home as an optional using the “home” crate
load_settings
Loads a given settings file from the home directory and the given crate name. Given my_cool_rust_project, the program would search in /home/username/my_cool_rust_project for a settings file
load_settings_with_filename
Loads a settings serialized file from USER_HOME/crate_name/file_name
save_settings
Saves the settings file given in a directory named using the crate name Given a struct and a crate name of my_cool_rust_project, the program would save it to /home/username/my_cool_rust_project/my_cool_rust_project.ser
save_settings_with_filename
Saves a serializable settings object to a given filename in USER_HOME/crate_name/file_name