Struct Ini

Source
pub struct Ini { /* private fields */ }

Implementations§

Source§

impl Ini

Source

pub fn new() -> Self

Create a new INI instance, preset a general section (None)

Source

pub fn set_section(&mut self, section_name: &str)

Ensure a named section exists in the INI document.

If the section does not exist, it will be created. The general section (None) cannot be created explicitly.

§Arguments
  • section_name - The name of the section to ensure exists.
Source

pub fn set_property<T: ToString>( &mut self, section_name: Option<&str>, key: &str, value: Option<T>, ) -> Result<(), ConfigError>

Set a property value in a section.

The section must already exist. If the property does not exist, it will be created; if it exists, it will be overwritten. If value is Some, sets the key-value pair; if None, sets only the key name (no value).

§Arguments
  • section_name - The section name (None for general section).
  • key - The property key.
  • value - The property value (optional).
§Errors

Returns ConfigError::SectionNotFound if the section does not exist.

Source

pub fn set_section_doc( &mut self, section_name: Option<&str>, doc_texts: Vec<String>, ) -> Result<(), ConfigError>

Set documentation comments for a section.

§Arguments
  • section_name - The section name (None for general section).
  • doc_texts - Documentation lines to associate with the section.
§Errors

Returns ConfigError::SectionNotFound if the section does not exist.

Source

pub fn set_property_doc( &mut self, section_name: Option<&str>, key: &str, doc_texts: Vec<String>, ) -> Result<(), ConfigError>

Set documentation comments for a property.

§Arguments
  • section_name - The section name (None for general section).
  • key - The property key.
  • doc_texts - Documentation lines to associate with the property.
§Errors

Returns ConfigError::SectionNotFound if the section does not exist, or ConfigError::PropertyNotFound if the property does not exist.

Source

pub fn get_value<T: FromStr>( &self, section_name: Option<&str>, key: &str, ) -> Result<Option<T>, T::Err>

Get the value of the specified section and key, parse to the specified type via FromStr

Source

pub fn get_string(&self, section_name: Option<&str>, key: &str) -> Option<&str>

Get the raw string value of the specified section and key

Source

pub fn has_property(&self, section_name: Option<&str>, key: &str) -> bool

Check if the specified property exists

Source

pub fn remove_property(&mut self, section_name: Option<&str>, key: &str) -> bool

Remove the specified property

Source

pub fn remove_section(&mut self, section_name: Option<&str>) -> bool

Remove the specified section

Source

pub fn sections(&self) -> &Map<SectionKey, SectionDocument>

Get all sections

Source

pub fn section(&self, name: Option<&str>) -> Option<&SectionDocument>

Get the specified section properties

Source

pub fn section_mut( &mut self, name: Option<&str>, ) -> Option<&mut SectionDocument>

Get a mutable reference to the specified section properties

Trait Implementations§

Source§

impl Display for Ini

Source§

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

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

impl From<ReadonlyIni> for Ini

Source§

fn from(readonly_ini: ReadonlyIni) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Ini

Source§

type Err = IniError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl TryFrom<Vec<Item<'_>>> for Ini

Source§

type Error = IniError

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

fn try_from(value: Vec<Item<'_>>) -> Result<Self, Self::Error>

Performs the conversion.

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.