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 get(&self, key: String) -> Value

Get

Get a serde_json Value with a specified key

Source

pub fn set(&mut self, key: String, val: Value)

Set

Set a value with a specified key and serde_json Value

Source

pub fn get_st(&self, key: &str) -> Value

Get (Static)

Get a serde_json Value with a specified key

Source

pub fn set_st(&mut self, key: &str, val: Value)

Set (Static)

Set a value with a specified key and serde_json Value

Source

pub fn set_str_st(&mut self, key: &str, val: &str)

Set String (Static)

Set a value with a specified key and static string

Source

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)

Source

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

Delete (Static)

Removes an entry with a specified key. Returns an option with the deleted Value (if it exists)

Source

pub fn has(&self, key: String) -> bool

Has Key

Checks if a key exists with a specified name

Source

pub fn has_st(&self, key: &str) -> bool

Has Key (Static)

Checks if a key exists with a specified name

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

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§

§

impl Freeze for FigCon

§

impl RefUnwindSafe for FigCon

§

impl Send for FigCon

§

impl Sync for FigCon

§

impl Unpin for FigCon

§

impl UnwindSafe for FigCon

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.