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§
- Load
Settings Error - Enum state representing the possible errors that can occur when loading settings
- Save
Settings Error - 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