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 with_general_section(&mut self) -> SectionSetter<'_>
pub fn with_general_section(&mut self) -> SectionSetter<'_>
Set with general section, a simple wrapper of with_section(None::<String>)
Sourcepub fn general_section(&self) -> &Properties
pub fn general_section(&self) -> &Properties
Get the immmutable general section
Sourcepub fn general_section_mut(&mut self) -> &mut Properties
pub fn general_section_mut(&mut self) -> &mut Properties
Get the mutable general section
Sourcepub fn section<S>(&self, name: Option<S>) -> Option<&Properties>
pub fn section<S>(&self, name: Option<S>) -> Option<&Properties>
Get a immutable section
Sourcepub fn section_mut<S>(&mut self, name: Option<S>) -> Option<&mut Properties>
pub fn section_mut<S>(&mut self, name: Option<S>) -> Option<&mut Properties>
Get a mutable section
Sourcepub fn section_all<S>(
&self,
name: Option<S>,
) -> impl DoubleEndedIterator<Item = &Properties>
pub fn section_all<S>( &self, name: Option<S>, ) -> impl DoubleEndedIterator<Item = &Properties>
Get all sections immutable with the same key
Sourcepub fn section_all_mut<S>(
&mut self,
name: Option<S>,
) -> impl DoubleEndedIterator<Item = &mut Properties>
pub fn section_all_mut<S>( &mut self, name: Option<S>, ) -> impl DoubleEndedIterator<Item = &mut Properties>
Get all sections mutable with the same key
Sourcepub fn entry(&mut self, name: Option<String>) -> SectionEntry<'_>
pub fn entry(&mut self, name: Option<String>) -> SectionEntry<'_>
Get the entry
Sourcepub fn sections(&self) -> impl DoubleEndedIterator<Item = Option<&str>>
pub fn sections(&self) -> impl DoubleEndedIterator<Item = Option<&str>>
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 first value from the sections 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 first value from the sections 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 mut str>
pub fn get_from_mut<'a, S>( &'a mut self, section: Option<S>, key: &str, ) -> Option<&'a mut str>
Get the first mutable value from the sections with key
Sourcepub fn delete<S>(&mut self, section: Option<S>) -> Option<Properties>
pub fn delete<S>(&mut self, section: Option<S>) -> Option<Properties>
Delete the first section with key, return the properties if it exists
Source§impl Ini
impl Ini
Sourcepub fn write_to_file_policy<P: AsRef<Path>>(
&self,
filename: P,
policy: EscapePolicy,
) -> Result<()>
pub fn write_to_file_policy<P: AsRef<Path>>( &self, filename: P, policy: EscapePolicy, ) -> Result<()>
Write to a file
Sourcepub fn write_to_file_opt<P: AsRef<Path>>(
&self,
filename: P,
opt: WriteOption,
) -> Result<()>
pub fn write_to_file_opt<P: AsRef<Path>>( &self, filename: P, opt: WriteOption, ) -> Result<()>
Write to a file with options
Sourcepub fn write_to_policy<W: Write>(
&self,
writer: &mut W,
policy: EscapePolicy,
) -> Result<()>
pub fn write_to_policy<W: Write>( &self, writer: &mut W, policy: EscapePolicy, ) -> Result<()>
Write to a writer
Sourcepub fn write_to_opt<W: Write>(
&self,
writer: &mut W,
opt: WriteOption,
) -> Result<()>
pub fn write_to_opt<W: Write>( &self, writer: &mut W, opt: WriteOption, ) -> Result<()>
Write to a writer with options
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: Read>(reader: &mut R) -> Result<Ini, Error>
pub fn read_from_noescape<R: Read>(reader: &mut R) -> Result<Ini, Error>
Load from a reader, but do not interpret ’' as an escape character
Sourcepub fn read_from_opt<R: Read>(
reader: &mut R,
opt: ParseOption,
) -> Result<Ini, Error>
pub fn read_from_opt<R: Read>( reader: &mut R, opt: ParseOption, ) -> Result<Ini, Error>
Load from a reader with options
Sourcepub fn load_from_file_noescape<P: AsRef<Path>>(
filename: P,
) -> Result<Ini, Error>
pub fn load_from_file_noescape<P: AsRef<Path>>( filename: P, ) -> Result<Ini, Error>
Load from a file, but do not interpret ’' as an escape character
Sourcepub fn load_from_file_opt<P: AsRef<Path>>(
filename: P,
opt: ParseOption,
) -> Result<Ini, Error>
pub fn load_from_file_opt<P: AsRef<Path>>( 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) -> SectionIter<'a> ⓘ
pub fn iter(&'a self) -> SectionIter<'a> ⓘ
Immutable iterate though sections
Sourcepub fn mut_iter(&'a mut self) -> SectionIterMut<'a> ⓘ
👎Deprecated: Use iter_mut
instead!
pub fn mut_iter(&'a mut self) -> SectionIterMut<'a> ⓘ
iter_mut
instead!Mutable iterate though sections
Sourcepub fn iter_mut(&'a mut self) -> SectionIterMut<'a> ⓘ
pub fn iter_mut(&'a mut self) -> SectionIterMut<'a> ⓘ
Mutable iterate though sections