Skip to main content

FigCon

Struct FigCon 

Source
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

Source

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

Source

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

Source

pub fn reload(&mut self) -> Self

§Reload Config

Pull the config file again and overwrite the config in memory

Source

pub fn save(&self)

§Save Config

Write the current config state synchronously to the file system

Source

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

Source

pub fn list_keys(&self) -> Option<Vec<String>>

§List Keys

Attempts to return all keys within an object

Source

pub fn list_values(&self) -> Option<Vec<Value>>

§List Values

Attempts to return all values within an object

Source

pub fn iter_keys(&mut self) -> Option<Keys<'_>>

§Iterate Keys

Attempts to return an iterator for the keys within the current object.

Source

pub fn iter_values(&mut self) -> Option<Values<'_>>

§Iterate Values

Attempts to return an iterator for the values within the current object.

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn get_obj_mut(&mut self, key: String) -> Option<&mut Value>

§Get Object (Mutable)

Get an object within the keys

Will return None if used on non-objects

Source

pub fn get_obj_mut_st(&mut self, key: &str) -> Option<&mut Value>

§Get Object (Mutable, Static)

Get an object within the keys

Will return None if used on non-objects

Source

pub fn get_obj(&self, key: String) -> Option<&Value>

§Get Object

Get an object within the keys

Will return None if used on non-objects

Source

pub fn get_obj_st(&self, key: &str) -> Option<&Value>

§Get Object (Static)

Get an object within the keys

Will return None if used on non-objects

Source

pub fn new_obj(&mut self, key: String) -> &mut Value

§New Object

Create a child structure within the current config with a given key

Source

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

Trait Implementations§

Source§

impl Clone for FigCon

Source§

fn clone(&self) -> FigCon

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FigCon

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for FigCon

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

§Format

A potentially slow function which attempts to display the entire configuration as a prettified json string

It would be inadvisable to use this on larger configurations during runtime

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.