Ini

Struct Ini 

Source
pub struct Ini {
    pub config_map: BTreeMap<String, BTreeMap<String, String>>,
    pub config_file: String,
}
Expand description

Load INI files into a structured BTreeMap, then edit them. Can also create new INI files. You can access the data directly via config_map, or use the provided functions. This only works on Windows and Linux

Fields§

§config_map: BTreeMap<String, BTreeMap<String, String>>§config_file: String

Implementations§

Source§

impl Ini

Source

pub fn new(location: String) -> Result<Ini, Error>

Load in an INI file and return its structure. If the file doesn’t exist, then returns empty structure.

Source

pub fn from_string(str: String) -> Result<Ini, Error>

Create ini structure from a string. Does not set the config_file so save doesn’t work unless set manually.

Source

pub fn to_string(&self) -> Result<String, Error>

Dump out the INI file to a string, returns blank string if no data is present

Source

pub fn save(&self) -> Result<usize, Error>

Save an INI file after being edited. Only functions correctly on Windows and Linux. Ok will contain the size in bytes of the file after writing. All comments in the INI file will be lost by doing this.

Source

pub fn get(&self, section: &str, key: &str) -> Option<String>

Get a value from the INI file.

Source

pub fn set(&mut self, section: &str, key: &str, value: &str)

Set a value in the INI file. If the section doesn’t exist, it will be created. If the key doesn’t exist, it will be created. This will not save the file.

Source

pub fn remove(&mut self, section: &str, key: &str)

Remove a key from the INI file. If the section doesn’t exist, it will be created. If the key doesn’t exist, it will be created. This will not save the file.

Source

pub fn remove_section(&mut self, section: &str)

Remove a section from the INI file. This will not save the file.

Trait Implementations§

Source§

impl Display for Ini

Display trait. Returns the string dump of INI data

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Ini

§

impl RefUnwindSafe for Ini

§

impl Send for Ini

§

impl Sync for Ini

§

impl Unpin for Ini

§

impl UnwindSafe for Ini

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> 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> 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.