pub struct Ini { /* private fields */ }
Expand description
Ini struct
Implementations
sourceimpl Ini
impl Ini
sourcepub fn with_section<S>(&mut self, section: Option<S>) -> SectionSetter<'_> where
S: Into<String>,
pub fn with_section<S>(&mut self, section: Option<S>) -> SectionSetter<'_> where
S: Into<String>,
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> where
S: Into<String>,
pub fn section<S>(&self, name: Option<S>) -> Option<&Properties> where
S: Into<String>,
Get a immutable section
sourcepub fn section_mut<S>(&mut self, name: Option<S>) -> Option<&mut Properties> where
S: Into<String>,
pub fn section_mut<S>(&mut self, name: Option<S>) -> Option<&mut Properties> where
S: Into<String>,
Get a mutable section
sourcepub fn section_all<S>(
&self,
name: Option<S>
) -> impl DoubleEndedIterator<Item = &Properties> where
S: Into<String>,
pub fn section_all<S>(
&self,
name: Option<S>
) -> impl DoubleEndedIterator<Item = &Properties> where
S: Into<String>,
Get all sections immutable with the same key
sourcepub fn section_all_mut<S>(
&mut self,
name: Option<S>
) -> impl DoubleEndedIterator<Item = &mut Properties> where
S: Into<String>,
pub fn section_all_mut<S>(
&mut self,
name: Option<S>
) -> impl DoubleEndedIterator<Item = &mut Properties> where
S: Into<String>,
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) where
S: Into<String>,
pub fn set_to<S>(&mut self, section: Option<S>, key: String, value: String) where
S: Into<String>,
Set key-value to a section
sourcepub fn get_from<'a, S>(
&'a self,
section: Option<S>,
key: &str
) -> Option<&'a str> where
S: Into<String>,
pub fn get_from<'a, S>(
&'a self,
section: Option<S>,
key: &str
) -> Option<&'a str> where
S: Into<String>,
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 where
S: Into<String>,
pub fn get_from_or<'a, S>(
&'a self,
section: Option<S>,
key: &str,
default: &'a str
) -> &'a str where
S: Into<String>,
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> where
S: Into<String>,
pub fn get_from_mut<'a, S>(
&'a mut self,
section: Option<S>,
key: &str
) -> Option<&'a mut str> where
S: Into<String>,
Get the first mutable value from the sections with key
sourcepub fn delete<S>(&mut self, section: Option<S>) -> Option<Properties> where
S: Into<String>,
pub fn delete<S>(&mut self, section: Option<S>) -> Option<Properties> where
S: Into<String>,
Delete the first section with key, return the properties if it exists
sourceimpl 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
sourceimpl 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
sourceimpl<'a> Ini
impl<'a> Ini
sourcepub fn iter(&'a self) -> SectionIter<'a>ⓘNotable traits for SectionIter<'a>impl<'a> Iterator for SectionIter<'a> type Item = (Option<&'a str>, &'a Properties);
pub fn iter(&'a self) -> SectionIter<'a>ⓘNotable traits for SectionIter<'a>impl<'a> Iterator for SectionIter<'a> type Item = (Option<&'a str>, &'a Properties);
Immutable iterate though sections
sourcepub fn mut_iter(&'a mut self) -> SectionIterMut<'a>ⓘNotable traits for SectionIterMut<'a>impl<'a> Iterator for SectionIterMut<'a> type Item = (Option<&'a str>, &'a mut Properties);
👎 Deprecated: Use iter_mut
instead!
pub fn mut_iter(&'a mut self) -> SectionIterMut<'a>ⓘNotable traits for SectionIterMut<'a>impl<'a> Iterator for SectionIterMut<'a> type Item = (Option<&'a str>, &'a mut Properties);
Use iter_mut
instead!
Mutable iterate though sections
sourcepub fn iter_mut(&'a mut self) -> SectionIterMut<'a>ⓘNotable traits for SectionIterMut<'a>impl<'a> Iterator for SectionIterMut<'a> type Item = (Option<&'a str>, &'a mut Properties);
pub fn iter_mut(&'a mut self) -> SectionIterMut<'a>ⓘNotable traits for SectionIterMut<'a>impl<'a> Iterator for SectionIterMut<'a> type Item = (Option<&'a str>, &'a mut Properties);
Mutable iterate though sections
Trait Implementations
sourceimpl<'q> Index<&'q str> for Ini
impl<'q> Index<&'q str> for Ini
type Output = Properties
type Output = Properties
The returned type after indexing.
sourcefn index<'a>(&'a self, index: &'q str) -> &'a Properties
fn index<'a>(&'a self, index: &'q str) -> &'a Properties
Performs the indexing (container[index]
) operation. Read more
sourceimpl<S: Into<String>> Index<Option<S>> for Ini
impl<S: Into<String>> Index<Option<S>> for Ini
type Output = Properties
type Output = Properties
The returned type after indexing.
sourcefn index(&self, index: Option<S>) -> &Properties
fn index(&self, index: Option<S>) -> &Properties
Performs the indexing (container[index]
) operation. Read more
sourceimpl<'q> IndexMut<&'q str> for Ini
impl<'q> IndexMut<&'q str> for Ini
sourcefn index_mut<'a>(&'a mut self, index: &'q str) -> &'a mut Properties
fn index_mut<'a>(&'a mut self, index: &'q str) -> &'a mut Properties
Performs the mutable indexing (container[index]
) operation. Read more
sourceimpl<S: Into<String>> IndexMut<Option<S>> for Ini
impl<S: Into<String>> IndexMut<Option<S>> for Ini
sourcefn index_mut(&mut self, index: Option<S>) -> &mut Properties
fn index_mut(&mut self, index: Option<S>) -> &mut Properties
Performs the mutable indexing (container[index]
) operation. Read more
sourceimpl<'a> IntoIterator for &'a Ini
impl<'a> IntoIterator for &'a Ini
sourceimpl<'a> IntoIterator for &'a mut Ini
impl<'a> IntoIterator for &'a mut Ini
Auto Trait Implementations
impl RefUnwindSafe for Ini
impl Send for Ini
impl Sync for Ini
impl Unpin for Ini
impl UnwindSafe for Ini
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more