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: boolSave any line within a section even if it doesn’t follow the key=value format
allow_dup_section_titles: boolAllow section titles to appear multiple times
keep_empty_section: boolKeep empty sections while parsing
store_isolated_line: boolStore isolated lines (lines before any section)
Implementations§
Source§impl IniReader
impl IniReader
Sourcepub fn exclude_section(&mut self, section: &str)
pub fn exclude_section(&mut self, section: &str)
Add a section to be excluded during parsing
Sourcepub fn include_section(&mut self, section: &str)
pub fn include_section(&mut self, section: &str)
Add a section to be included during parsing
Sourcepub fn add_direct_save_section(&mut self, section: &str)
pub fn add_direct_save_section(&mut self, section: &str)
Add a section to be saved directly without processing
Sourcepub fn set_isolated_items_section(&mut self, section: &str)
pub fn set_isolated_items_section(&mut self, section: &str)
Set the section to store isolated items
Sourcepub fn erase_section(&mut self)
pub fn erase_section(&mut self)
Erase all contents of the current section (keeps the section, just empties it)
Sourcepub fn erase_section_by_name(&mut self, section: &str)
pub fn erase_section_by_name(&mut self, section: &str)
Erase all items in a specific section but keep the section itself
Sourcepub async fn from_file(path: &str) -> Result<Self, IniReaderError>
pub async fn from_file(path: &str) -> Result<Self, IniReaderError>
Create a new INI reader and parse a file
Sourcepub fn get_last_error(&self) -> String
pub fn get_last_error(&self) -> String
Get the last error as a string
Sourcepub fn parse(&mut self, content: &str) -> Result<(), IniReaderError>
pub fn parse(&mut self, content: &str) -> Result<(), IniReaderError>
Parse INI content into the internal data structure
Sourcepub async fn parse_file(&mut self, path: &str) -> Result<(), IniReaderError>
pub async fn parse_file(&mut self, path: &str) -> Result<(), IniReaderError>
Parse an INI file
Sourcepub fn section_exist(&self, section: &str) -> bool
pub fn section_exist(&self, section: &str) -> bool
Check if a section exists
Sourcepub fn section_count(&self) -> usize
pub fn section_count(&self) -> usize
Get the count of sections
Sourcepub fn get_section_names(&self) -> &[String]
pub fn get_section_names(&self) -> &[String]
Get all section names
Sourcepub fn set_current_section(&mut self, section: &str)
pub fn set_current_section(&mut self, section: &str)
Set the current section
Sourcepub fn enter_section(&mut self, section: &str) -> Result<(), IniReaderError>
pub fn enter_section(&mut self, section: &str) -> Result<(), IniReaderError>
Enter a section with the given name
Sourcepub fn item_exist(&self, section: &str, item_name: &str) -> bool
pub fn item_exist(&self, section: &str, item_name: &str) -> bool
Check if an item exists in the given section
Sourcepub fn item_exist_current(&self, item_name: &str) -> bool
pub fn item_exist_current(&self, item_name: &str) -> bool
Check if an item exists in the current section
Sourcepub fn item_prefix_exists(&self, section: &str, prefix: &str) -> bool
pub fn item_prefix_exists(&self, section: &str, prefix: &str) -> bool
Check if an item with given prefix exists in the section
Sourcepub fn item_prefix_exist(&self, prefix: &str) -> bool
pub fn item_prefix_exist(&self, prefix: &str) -> bool
Check if an item with given prefix exists in the current section
Sourcepub fn get_items(
&self,
section: &str,
) -> Result<Vec<(String, String)>, IniReaderError>
pub fn get_items( &self, section: &str, ) -> Result<Vec<(String, String)>, IniReaderError>
Get all items in a section
Sourcepub fn get_all(
&self,
section: &str,
item_name: &str,
) -> Result<Vec<String>, IniReaderError>
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
Sourcepub fn get_all_current(
&self,
item_name: &str,
) -> Result<Vec<String>, IniReaderError>
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
Sourcepub fn get(&self, section: &str, item_name: &str) -> String
pub fn get(&self, section: &str, item_name: &str) -> String
Get an item with the exact same name in the given section
Sourcepub fn get_current(&self, item_name: &str) -> String
pub fn get_current(&self, item_name: &str) -> String
Get an item with the exact same name in the current section
Sourcepub fn get_bool(&self, section: &str, item_name: &str) -> bool
pub fn get_bool(&self, section: &str, item_name: &str) -> bool
Get a boolean value from the given section
Sourcepub fn get_bool_current(&self, item_name: &str) -> bool
pub fn get_bool_current(&self, item_name: &str) -> bool
Get a boolean value from the current section
Sourcepub fn get_int(&self, section: &str, item_name: &str) -> i32
pub fn get_int(&self, section: &str, item_name: &str) -> i32
Get an integer value from the given section
Sourcepub fn get_int_current(&self, item_name: &str) -> i32
pub fn get_int_current(&self, item_name: &str) -> i32
Get an integer value from the current section
Sourcepub fn set(
&mut self,
section: &str,
item_name: &str,
item_val: &str,
) -> Result<(), IniReaderError>
pub fn set( &mut self, section: &str, item_name: &str, item_val: &str, ) -> Result<(), IniReaderError>
Set a value in the given section
Sourcepub fn set_current(
&mut self,
item_name: &str,
item_val: &str,
) -> Result<(), IniReaderError>
pub fn set_current( &mut self, item_name: &str, item_val: &str, ) -> Result<(), IniReaderError>
Set a value in the current section
Sourcepub fn set_bool(
&mut self,
section: &str,
item_name: &str,
item_val: bool,
) -> Result<(), IniReaderError>
pub fn set_bool( &mut self, section: &str, item_name: &str, item_val: bool, ) -> Result<(), IniReaderError>
Set a boolean value in the given section
Sourcepub fn set_bool_current(
&mut self,
item_name: &str,
item_val: bool,
) -> Result<(), IniReaderError>
pub fn set_bool_current( &mut self, item_name: &str, item_val: bool, ) -> Result<(), IniReaderError>
Set a boolean value in the current section
Sourcepub fn set_int(
&mut self,
section: &str,
item_name: &str,
item_val: i32,
) -> Result<(), IniReaderError>
pub fn set_int( &mut self, section: &str, item_name: &str, item_val: i32, ) -> Result<(), IniReaderError>
Set an integer value in the given section
Sourcepub fn set_int_current(
&mut self,
item_name: &str,
item_val: i32,
) -> Result<(), IniReaderError>
pub fn set_int_current( &mut self, item_name: &str, item_val: i32, ) -> Result<(), IniReaderError>
Set an integer value in the current section
Sourcepub fn set_current_with_noname(
&mut self,
item_val: &str,
) -> Result<(), IniReaderError>
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”)