IniReader

Struct IniReader 

Source
pub struct IniReader {
    pub store_any_line: bool,
    pub allow_dup_section_titles: bool,
    pub keep_empty_section: bool,
    pub store_isolated_line: bool,
    /* private fields */
}
Expand description

Custom INI reader implementation similar to C++ INIReader

Fields§

§store_any_line: bool

Save any line within a section even if it doesn’t follow the key=value format

§allow_dup_section_titles: bool

Allow section titles to appear multiple times

§keep_empty_section: bool

Keep empty sections while parsing

§store_isolated_line: bool

Store isolated lines (lines before any section)

Implementations§

Source§

impl IniReader

Source

pub fn new() -> Self

Create a new INI reader

Source

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

Add a section to be excluded during parsing

Source

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

Add a section to be included during parsing

Source

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

Add a section to be saved directly without processing

Source

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

Set the section to store isolated items

Source

pub fn erase_section(&mut self)

Erase all contents of the current section (keeps the section, just empties it)

Source

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

Erase all items in a specific section but keep the section itself

Source

pub async fn from_file(path: &str) -> Result<Self, IniReaderError>

Create a new INI reader and parse a file

Source

pub fn get_last_error(&self) -> String

Get the last error as a string

Source

pub fn erase_all(&mut self)

Erase all data from the INI

Source

pub fn is_parsed(&self) -> bool

Check if parsed successfully

Source

pub fn parse(&mut self, content: &str) -> Result<(), IniReaderError>

Parse INI content into the internal data structure

Source

pub async fn parse_file(&mut self, path: &str) -> Result<(), IniReaderError>

Parse an INI file

Source

pub fn section_exist(&self, section: &str) -> bool

Check if a section exists

Source

pub fn section_count(&self) -> usize

Get the count of sections

Source

pub fn get_section_names(&self) -> &[String]

Get all section names

Source

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

Set the current section

Source

pub fn enter_section(&mut self, section: &str) -> Result<(), IniReaderError>

Enter a section with the given name

Source

pub fn item_exist(&self, section: &str, item_name: &str) -> bool

Check if an item exists in the given section

Source

pub fn item_exist_current(&self, item_name: &str) -> bool

Check if an item exists in the current section

Source

pub fn item_prefix_exists(&self, section: &str, prefix: &str) -> bool

Check if an item with given prefix exists in the section

Source

pub fn item_prefix_exist(&self, prefix: &str) -> bool

Check if an item with given prefix exists in the current section

Source

pub fn get_items( &self, section: &str, ) -> Result<Vec<(String, String)>, IniReaderError>

Get all items in a section

Source

pub fn get_all( &self, section: &str, item_name: &str, ) -> Result<Vec<String>, IniReaderError>

Get all items with the same name prefix in a section

Source

pub fn get_all_current( &self, item_name: &str, ) -> Result<Vec<String>, IniReaderError>

Get all items with the same name prefix in the current section

Source

pub fn get(&self, section: &str, item_name: &str) -> String

Get an item with the exact same name in the given section

Source

pub fn get_current(&self, item_name: &str) -> String

Get an item with the exact same name in the current section

Source

pub fn get_bool(&self, section: &str, item_name: &str) -> bool

Get a boolean value from the given section

Source

pub fn get_bool_current(&self, item_name: &str) -> bool

Get a boolean value from the current section

Source

pub fn get_int(&self, section: &str, item_name: &str) -> i32

Get an integer value from the given section

Source

pub fn get_int_current(&self, item_name: &str) -> i32

Get an integer value from the current section

Source

pub fn set( &mut self, section: &str, item_name: &str, item_val: &str, ) -> Result<(), IniReaderError>

Set a value in the given section

Source

pub fn set_current( &mut self, item_name: &str, item_val: &str, ) -> Result<(), IniReaderError>

Set a value in the current section

Source

pub fn set_bool( &mut self, section: &str, item_name: &str, item_val: bool, ) -> Result<(), IniReaderError>

Set a boolean value in the given section

Source

pub fn set_bool_current( &mut self, item_name: &str, item_val: bool, ) -> Result<(), IniReaderError>

Set a boolean value in the current section

Source

pub fn set_int( &mut self, section: &str, item_name: &str, item_val: i32, ) -> Result<(), IniReaderError>

Set an integer value in the given section

Source

pub fn set_int_current( &mut self, item_name: &str, item_val: i32, ) -> Result<(), IniReaderError>

Set an integer value in the current section

Source

pub fn to_string(&self) -> String

Export the INI to a string

Source

pub fn to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>

Export the INI to a file

Source

pub fn set_current_with_noname( &mut self, item_val: &str, ) -> Result<(), IniReaderError>

Set a value in the current section with {NONAME} key This is used in patterns like set_current(“{NONAME}”, “value”)

Trait Implementations§

Source§

impl Default for IniReader

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T