pub struct FigCon { /* private fields */ }Expand description
FigCon
A simple synchronous config manager that relies on serde_json
It stores its own path location and can be saved/reloaded at any time
Implementations§
Source§impl FigCon
impl FigCon
Sourcepub fn load_or_default(path: PathBuf) -> Self
pub fn load_or_default(path: PathBuf) -> Self
Initialize the FigCon
Attempts to load a config file with the given PathBuf and returns an empty FigCon when it fails
Sourcepub fn set_path(&mut self, path: PathBuf)
pub fn set_path(&mut self, path: PathBuf)
Set Config Path
Changing the location during runtime will not affect the live config, and it will not save to the new location automatically.
Use .save() immediately after if you wish to write the live config to the new location
Sourcepub fn reload(&mut self) -> Self
pub fn reload(&mut self) -> Self
Reload Config
Pull the config file again and overwrite the config in memory
Sourcepub fn set(&mut self, key: String, val: Value)
pub fn set(&mut self, key: String, val: Value)
Set
Set a value with a specified key and serde_json Value
Sourcepub fn get_st(&self, key: &str) -> Value
pub fn get_st(&self, key: &str) -> Value
Get (Static)
Get a serde_json Value with a specified key
Sourcepub fn set_st(&mut self, key: &str, val: Value)
pub fn set_st(&mut self, key: &str, val: Value)
Set (Static)
Set a value with a specified key and serde_json Value
Sourcepub fn set_str_st(&mut self, key: &str, val: &str)
pub fn set_str_st(&mut self, key: &str, val: &str)
Set String (Static)
Set a value with a specified key and static string
Sourcepub fn del(&mut self, key: String) -> Option<Value>
pub fn del(&mut self, key: String) -> Option<Value>
Delete
Removes an entry with a specified key. Returns an option with the deleted Value (if it exists)