#[repr(transparent)]pub struct KeyFile { /* private fields */ }
Implementations
sourceimpl KeyFile
impl KeyFile
pub fn new() -> KeyFile
pub fn comment(
&self,
group_name: Option<&str>,
key: Option<&str>
) -> Result<GString, Error>
pub fn double(&self, group_name: &str, key: &str) -> Result<f64, Error>
pub fn double_list(
&self,
group_name: &str,
key: &str
) -> Result<Vec<f64>, Error>
pub fn groups(&self) -> (Vec<GString>, usize)
pub fn int64(&self, group_name: &str, key: &str) -> Result<i64, Error>
pub fn integer(&self, group_name: &str, key: &str) -> Result<i32, Error>
pub fn integer_list(
&self,
group_name: &str,
key: &str
) -> Result<Vec<i32>, Error>
pub fn keys(&self, group_name: &str) -> Result<(Vec<GString>, usize), Error>
pub fn locale_for_key(
&self,
group_name: &str,
key: &str,
locale: Option<&str>
) -> Option<GString>
v2_56
only.pub fn start_group(&self) -> Option<GString>
pub fn uint64(&self, group_name: &str, key: &str) -> Result<u64, Error>
pub fn value(&self, group_name: &str, key: &str) -> Result<GString, Error>
pub fn has_group(&self, group_name: &str) -> bool
pub fn load_from_bytes(
&self,
bytes: &Bytes,
flags: KeyFileFlags
) -> Result<(), Error>
v2_50
only.pub fn load_from_data(
&self,
data: &str,
flags: KeyFileFlags
) -> Result<(), Error>
pub fn load_from_file(
&self,
file: impl AsRef<Path>,
flags: KeyFileFlags
) -> Result<(), Error>
pub fn remove_comment(
&self,
group_name: Option<&str>,
key: Option<&str>
) -> Result<(), Error>
pub fn remove_group(&self, group_name: &str) -> Result<(), Error>
pub fn remove_key(&self, group_name: &str, key: &str) -> Result<(), Error>
sourcepub fn set_boolean(&self, group_name: &str, key: &str, value: bool)
pub fn set_boolean(&self, group_name: &str, key: &str, value: bool)
Associates a new boolean value with key
under group_name
.
If key
cannot be found then it is created.
group_name
a group name
key
a key
value
sourcepub fn set_comment(
&self,
group_name: Option<&str>,
key: Option<&str>,
comment: &str
) -> Result<(), Error>
pub fn set_comment(
&self,
group_name: Option<&str>,
key: Option<&str>,
comment: &str
) -> Result<(), Error>
Places a comment above key
from group_name
.
If key
is None
then comment
will be written above group_name
.
If both key
and group_name
are None
, then comment
will be
written above the first group in the file.
Note that this function prepends a ‘#’ comment marker to
each line of comment
.
group_name
a group name, or None
key
a key
comment
a comment
Returns
sourcepub fn set_double(&self, group_name: &str, key: &str, value: f64)
pub fn set_double(&self, group_name: &str, key: &str, value: f64)
Associates a new double value with key
under group_name
.
If key
cannot be found then it is created.
group_name
a group name
key
a key
value
a double value
sourcepub fn set_int64(&self, group_name: &str, key: &str, value: i64)
pub fn set_int64(&self, group_name: &str, key: &str, value: i64)
Associates a new integer value with key
under group_name
.
If key
cannot be found then it is created.
group_name
a group name
key
a key
value
an integer value
sourcepub fn set_integer(&self, group_name: &str, key: &str, value: i32)
pub fn set_integer(&self, group_name: &str, key: &str, value: i32)
Associates a new integer value with key
under group_name
.
If key
cannot be found then it is created.
group_name
a group name
key
a key
value
an integer value
sourcepub fn set_list_separator(&self, separator: Char)
pub fn set_list_separator(&self, separator: Char)
Sets the character which is used to separate values in lists. Typically ‘;’ or ‘,’ are used as separators. The default list separator is ‘;’.
separator
the separator
sourcepub fn set_locale_string(
&self,
group_name: &str,
key: &str,
locale: &str,
string: &str
)
pub fn set_locale_string(
&self,
group_name: &str,
key: &str,
locale: &str,
string: &str
)
Associates a string value for key
and locale
under group_name
.
If the translation for key
cannot be found then it is created.
group_name
a group name
key
a key
locale
a locale identifier
string
a string
sourcepub fn set_string(&self, group_name: &str, key: &str, string: &str)
pub fn set_string(&self, group_name: &str, key: &str, string: &str)
Associates a new string value with key
under group_name
.
If key
cannot be found then it is created.
If group_name
cannot be found then it is created.
Unlike set_value()
, this function handles characters
that need escaping, such as newlines.
group_name
a group name
key
a key
string
a string
sourcepub fn set_uint64(&self, group_name: &str, key: &str, value: u64)
pub fn set_uint64(&self, group_name: &str, key: &str, value: u64)
Associates a new integer value with key
under group_name
.
If key
cannot be found then it is created.
group_name
a group name
key
a key
value
an integer value
sourcepub fn set_value(&self, group_name: &str, key: &str, value: &str)
pub fn set_value(&self, group_name: &str, key: &str, value: &str)
Associates a new value with key
under group_name
.
If key
cannot be found then it is created. If group_name
cannot
be found then it is created. To set an UTF-8 string which may contain
characters that need escaping (such as newlines or spaces), use
set_string()
.
group_name
a group name
key
a key
value
a string
sourceimpl KeyFile
impl KeyFile
pub fn save_to_file<T: AsRef<Path>>(&self, filename: T) -> Result<(), Error>
pub fn load_from_data_dirs<T: AsRef<Path>>(
&self,
file: T,
flags: KeyFileFlags
) -> Result<PathBuf, Error>
pub fn load_from_dirs<T: AsRef<Path>, U: AsRef<Path>>(
&self,
file: T,
search_dirs: &[U],
flags: KeyFileFlags
) -> Result<PathBuf, Error>
pub fn boolean(&self, group_name: &str, key: &str) -> Result<bool, Error>
pub fn has_key(&self, group_name: &str, key: &str) -> Result<bool, Error>
pub fn boolean_list(
&self,
group_name: &str,
key: &str
) -> Result<Vec<bool>, Error>
pub fn string(&self, group_name: &str, key: &str) -> Result<GString, Error>
pub fn string_list(
&self,
group_name: &str,
key: &str
) -> Result<Vec<GString>, Error>
pub fn locale_string(
&self,
group_name: &str,
key: &str,
locale: Option<&str>
) -> Result<GString, Error>
pub fn locale_string_list(
&self,
group_name: &str,
key: &str,
locale: Option<&str>
) -> Result<Vec<GString>, Error>
Trait Implementations
sourceimpl Ord for KeyFile
impl Ord for KeyFile
sourceimpl PartialOrd<KeyFile> for KeyFile
impl PartialOrd<KeyFile> for KeyFile
sourcefn partial_cmp(&self, other: &KeyFile) -> Option<Ordering>
fn partial_cmp(&self, other: &KeyFile) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl StaticType for KeyFile
impl StaticType for KeyFile
sourcefn static_type() -> Type
fn static_type() -> Type
Returns the type identifier of Self
.
impl Eq for KeyFile
impl StructuralEq for KeyFile
impl StructuralPartialEq for KeyFile
Auto Trait Implementations
impl RefUnwindSafe for KeyFile
impl !Send for KeyFile
impl !Sync for KeyFile
impl Unpin for KeyFile
impl UnwindSafe for KeyFile
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> StaticTypeExt for T where
T: StaticType,
impl<T> StaticTypeExt for T where
T: StaticType,
sourcefn ensure_type()
fn ensure_type()
Ensures that the type has been registered with the type system.