pub struct Ini { /* private fields */ }
Expand description
Ini struct
Implementations§
Source§impl Ini
impl Ini
Sourcepub fn with_section<S>(&mut self, section: Option<S>) -> SectionSetter<'_>
pub fn with_section<S>(&mut self, section: Option<S>) -> SectionSetter<'_>
Set with a specified section, None
is for the general section
Sourcepub fn general_section(&self) -> &HashMap<String, String>
pub fn general_section(&self) -> &HashMap<String, String>
Get the immmutable general section
Sourcepub fn general_section_mut(&mut self) -> &mut HashMap<String, String>
pub fn general_section_mut(&mut self) -> &mut HashMap<String, String>
Get the mutable general section
Sourcepub fn section<S>(&self, name: Option<S>) -> Option<&HashMap<String, String>>
pub fn section<S>(&self, name: Option<S>) -> Option<&HashMap<String, String>>
Get a immutable section
Sourcepub fn section_mut<S>(
&mut self,
name: Option<S>,
) -> Option<&mut HashMap<String, String>>
pub fn section_mut<S>( &mut self, name: Option<S>, ) -> Option<&mut HashMap<String, String>>
Get a mutable section
Sourcepub fn entry(
&mut self,
name: Option<String>,
) -> Entry<'_, Option<String>, HashMap<String, String>>
pub fn entry( &mut self, name: Option<String>, ) -> Entry<'_, Option<String>, HashMap<String, String>>
Get the entry
Sourcepub fn sections(&self) -> Keys<'_, Option<String>, HashMap<String, String>>
pub fn sections(&self) -> Keys<'_, Option<String>, HashMap<String, String>>
Iterate with sections
Sourcepub fn set_to<S>(&mut self, section: Option<S>, key: String, value: String)
pub fn set_to<S>(&mut self, section: Option<S>, key: String, value: String)
Set key-value to a section
Sourcepub fn get_from<'a, S>(
&'a self,
section: Option<S>,
key: &str,
) -> Option<&'a str>
pub fn get_from<'a, S>( &'a self, section: Option<S>, key: &str, ) -> Option<&'a str>
Get the value from a section with key
Example:
use ini::Ini;
let input = "[sec]\nabc = def\n";
let ini = Ini::load_from_str(input).unwrap();
assert_eq!(ini.get_from(Some("sec"), "abc"), Some("def"));
Sourcepub fn get_from_or<'a, S>(
&'a self,
section: Option<S>,
key: &str,
default: &'a str,
) -> &'a str
pub fn get_from_or<'a, S>( &'a self, section: Option<S>, key: &str, default: &'a str, ) -> &'a str
Get the value from a section with key, return the default value if it does not exist
Example:
use ini::Ini;
let input = "[sec]\n";
let ini = Ini::load_from_str(input).unwrap();
assert_eq!(ini.get_from_or(Some("sec"), "key", "default"), "default");
Sourcepub fn get_from_mut<'a, S>(
&'a mut self,
section: Option<S>,
key: &str,
) -> Option<&'a str>
pub fn get_from_mut<'a, S>( &'a mut self, section: Option<S>, key: &str, ) -> Option<&'a str>
Get the mutable from a section with key
Sourcepub fn delete<S>(
&mut self,
section: Option<S>,
) -> Option<HashMap<String, String>>
pub fn delete<S>( &mut self, section: Option<S>, ) -> Option<HashMap<String, String>>
Delete a section, return the properties if it exists
pub fn delete_from<S>( &mut self, section: Option<S>, key: &str, ) -> Option<String>
Source§impl Ini
impl Ini
Sourcepub fn write_to_file<P>(&self, filename: P) -> Result<(), Error>
pub fn write_to_file<P>(&self, filename: P) -> Result<(), Error>
Write to a file
Sourcepub fn write_to_file_policy<P>(
&self,
filename: P,
policy: EscapePolicy,
) -> Result<(), Error>
pub fn write_to_file_policy<P>( &self, filename: P, policy: EscapePolicy, ) -> Result<(), Error>
Write to a file
Sourcepub fn write_to<W>(&self, writer: &mut W) -> Result<(), Error>where
W: Write,
pub fn write_to<W>(&self, writer: &mut W) -> Result<(), Error>where
W: Write,
Write to a writer
Sourcepub fn write_to_policy<W>(
&self,
writer: &mut W,
policy: EscapePolicy,
) -> Result<(), Error>where
W: Write,
pub fn write_to_policy<W>(
&self,
writer: &mut W,
policy: EscapePolicy,
) -> Result<(), Error>where
W: Write,
Write to a writer
Source§impl Ini
impl Ini
Sourcepub fn load_from_str(buf: &str) -> Result<Ini, ParseError>
pub fn load_from_str(buf: &str) -> Result<Ini, ParseError>
Load from a string
Sourcepub fn load_from_str_noescape(buf: &str) -> Result<Ini, ParseError>
pub fn load_from_str_noescape(buf: &str) -> Result<Ini, ParseError>
Load from a string, but do not interpret ’' as an escape character
Sourcepub fn load_from_str_opt(buf: &str, opt: ParseOption) -> Result<Ini, ParseError>
pub fn load_from_str_opt(buf: &str, opt: ParseOption) -> Result<Ini, ParseError>
Load from a string with options
Sourcepub fn read_from_noescape<R>(reader: &mut R) -> Result<Ini, Error>where
R: Read,
pub fn read_from_noescape<R>(reader: &mut R) -> Result<Ini, Error>where
R: Read,
Load from a reader, but do not interpret ’' as an escape character
Sourcepub fn read_from_opt<R>(reader: &mut R, opt: ParseOption) -> Result<Ini, Error>where
R: Read,
pub fn read_from_opt<R>(reader: &mut R, opt: ParseOption) -> Result<Ini, Error>where
R: Read,
Load from a reader with options
Sourcepub fn load_from_file<P>(filename: P) -> Result<Ini, Error>
pub fn load_from_file<P>(filename: P) -> Result<Ini, Error>
Load from a file
Sourcepub fn load_from_file_noescape<P>(filename: P) -> Result<Ini, Error>
pub fn load_from_file_noescape<P>(filename: P) -> Result<Ini, Error>
Load from a file, but do not interpret ’' as an escape character
Sourcepub fn load_from_file_opt<P>(
filename: P,
opt: ParseOption,
) -> Result<Ini, Error>
pub fn load_from_file_opt<P>( filename: P, opt: ParseOption, ) -> Result<Ini, Error>
Load from a file with options
Source§impl<'a> Ini
impl<'a> Ini
Sourcepub fn iter(&'a self) -> SectionIterator<'a>
pub fn iter(&'a self) -> SectionIterator<'a>
Immutable iterate though sections
Sourcepub fn mut_iter(&'a mut self) -> SectionMutIterator<'a>
pub fn mut_iter(&'a mut self) -> SectionMutIterator<'a>
Mutable iterate though sections
Deprecated! Use iter_mut
instead!
Sourcepub fn iter_mut(&'a mut self) -> SectionMutIterator<'a>
pub fn iter_mut(&'a mut self) -> SectionMutIterator<'a>
Mutable iterate though sections