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 save(&self)
pub fn save(&self)
§Save Config
Write the current config state synchronously to the file system
Sourcepub fn any_keys(&self) -> bool
pub fn any_keys(&self) -> bool
§Any Keys
Returns true if the object contains any keys (Length > 0)
Automatically returns false if used on non-objects
Sourcepub fn list_keys(&self) -> Option<Vec<String>>
pub fn list_keys(&self) -> Option<Vec<String>>
§List Keys
Attempts to return all keys within an object
Sourcepub fn list_values(&self) -> Option<Vec<Value>>
pub fn list_values(&self) -> Option<Vec<Value>>
§List Values
Attempts to return all values within an object
Sourcepub fn iter_keys(&mut self) -> Option<Keys<'_>>
pub fn iter_keys(&mut self) -> Option<Keys<'_>>
§Iterate Keys
Attempts to return an iterator for the keys within the current object.
Sourcepub fn iter_values(&mut self) -> Option<Values<'_>>
pub fn iter_values(&mut self) -> Option<Values<'_>>
§Iterate Values
Attempts to return an iterator for the values within the current object.
Sourcepub fn get_key_mut(&mut self, key: String) -> Option<&mut Value>
pub fn get_key_mut(&mut self, key: String) -> Option<&mut Value>
§Get Key (Mutable)
Acquire a key’s value within an object within a value
Will return None if used on non-objects
Sourcepub fn get_key_mut_st(&mut self, key: &str) -> Option<&mut Value>
pub fn get_key_mut_st(&mut self, key: &str) -> Option<&mut Value>
§Get Key (Mutable, Static)
Acquire a key’s value within an object within a value
Will return None if used on non-objects
Sourcepub fn get_key(&self, key: String) -> Option<&Value>
pub fn get_key(&self, key: String) -> Option<&Value>
§Get Key
Acquire a key’s value within an object within a value
Will return None if used on non-objects
Sourcepub fn get_key_st(&self, key: &str) -> Option<&Value>
pub fn get_key_st(&self, key: &str) -> Option<&Value>
§Get Key (Static)
Acquire a key’s value within an object within a value
Will return None if used on non-objects
Sourcepub fn set_key(&mut self, key: String, value: Value)
pub fn set_key(&mut self, key: String, value: Value)
§Set Key
Assign a key’s value within an object within a value
Will do nothing if used on non-objects
Sourcepub fn set_key_st(&mut self, key: &str, value: Value)
pub fn set_key_st(&mut self, key: &str, value: Value)
§Set Key (Static)
Assign a key’s value within an object within a value
Will do nothing if used on non-objects
Sourcepub fn has_key(&self, key: String) -> bool
pub fn has_key(&self, key: String) -> bool
§Has Key
Check if a key exists within an object within a value
Automatically returns false if used on non-objects
Sourcepub fn has_key_st(&self, key: &str) -> bool
pub fn has_key_st(&self, key: &str) -> bool
§Has Key
Check if a key exists within an object within a value
Automatically returns false if used on non-objects
Sourcepub fn remove_get_key(&mut self, key: String) -> Option<Value>
pub fn remove_get_key(&mut self, key: String) -> Option<Value>
§Remove and Get Key
Remove an object’s key within a value and return it if it exists
Will return None if used on non-objects
Sourcepub fn remove_get_key_st(&mut self, key: &str) -> Option<Value>
pub fn remove_get_key_st(&mut self, key: &str) -> Option<Value>
§Remove and Get Key (Static)
Remove an object’s key within a value and return it if it exists
Will return None if used on non-objects
Sourcepub fn remove_key(&mut self, key: String)
pub fn remove_key(&mut self, key: String)
§Remove Key
Remove an object’s key within a value without respect to whether its assigned, or where its value goes
Will do nothing if used on non-objects
Sourcepub fn remove_key_st(&mut self, key: &str)
pub fn remove_key_st(&mut self, key: &str)
§Remove Key (Static)
Remove an object’s key within a value without respect to whether its assigned, or where its value goes
Will do nothing if used on non-objects
Sourcepub fn set_obj(&mut self, key: String, object: Value)
pub fn set_obj(&mut self, key: String, object: Value)
§Set Object
Overwrite an object within the value, and combine the keys inside
Will do nothing if used on non-objects
Sourcepub fn set_obj_st(&mut self, key: &str, object: Value)
pub fn set_obj_st(&mut self, key: &str, object: Value)
§Set Object (Static)
Overwrite an object within the value, and combine the keys inside
Will do nothing if used on non-objects
Sourcepub fn get_obj_mut(&mut self, key: String) -> Option<&mut Value>
pub fn get_obj_mut(&mut self, key: String) -> Option<&mut Value>
Sourcepub fn get_obj_mut_st(&mut self, key: &str) -> Option<&mut Value>
pub fn get_obj_mut_st(&mut self, key: &str) -> Option<&mut Value>
Sourcepub fn get_obj_st(&self, key: &str) -> Option<&Value>
pub fn get_obj_st(&self, key: &str) -> Option<&Value>
Sourcepub fn new_obj(&mut self, key: String) -> &mut Value
pub fn new_obj(&mut self, key: String) -> &mut Value
§New Object
Create a child structure within the current config with a given key
Sourcepub fn new_obj_st(&mut self, key: &str) -> &mut Value
pub fn new_obj_st(&mut self, key: &str) -> &mut Value
§New Object (Static)
Create a child structure within the current config with a given key