pub struct Group(/* private fields */);Expand description
A group/section in an INI/.desktop file (e.g., [Desktop Entry])
Implementations§
Source§impl Group
impl Group
Sourcepub fn name(&self) -> Option<String>
pub fn name(&self) -> Option<String>
Get the name of the group
Examples found in repository?
examples/test_parse.rs (line 19)
4fn main() {
5 let input = r###"[Desktop Entry]
6Name=Example Application
7Type=Application
8Exec=example
9# This is a comment
10Icon=example.png
11"###;
12
13 println!("Input:\n{}", input);
14 println!("\nParsing...");
15 match Desktop::from_str(input) {
16 Ok(desktop) => {
17 println!("Success! Groups: {}", desktop.groups().count());
18 for group in desktop.groups() {
19 println!("Group: {:?}", group.name());
20 }
21 }
22 Err(e) => {
23 println!("Error: {}", e);
24 }
25 }
26}Sourcepub fn get_locale(&self, key: &str, locale: &str) -> Option<String>
pub fn get_locale(&self, key: &str, locale: &str) -> Option<String>
Get a localized value for a key (e.g., get_locale(“Name”, “de”))
Sourcepub fn get_locales(&self, key: &str) -> Vec<String>
pub fn get_locales(&self, key: &str) -> Vec<String>
Get all locales for a given key
Sourcepub fn get_all(&self, key: &str) -> Vec<(Option<String>, String)>
pub fn get_all(&self, key: &str) -> Vec<(Option<String>, String)>
Get all entries for a key (including localized variants)
Sourcepub fn set(&mut self, key: &str, value: &str)
pub fn set(&mut self, key: &str, value: &str)
Set a value for a key (or add if it doesn’t exist)
Sourcepub fn set_locale(&mut self, key: &str, locale: &str, value: &str)
pub fn set_locale(&mut self, key: &str, locale: &str, value: &str)
Set a localized value for a key (e.g., set_locale(“Name”, “de”, “Beispiel”))
Sourcepub fn remove_locale(&mut self, key: &str, locale: &str)
pub fn remove_locale(&mut self, key: &str, locale: &str)
Remove a localized entry by key and locale
Sourcepub fn remove_all(&mut self, key: &str)
pub fn remove_all(&mut self, key: &str)
Remove all entries for a key (including all localized variants)
Sourcepub fn syntax(&self) -> &SyntaxNode<Lang>
pub fn syntax(&self) -> &SyntaxNode<Lang>
Get the raw syntax node
Trait Implementations§
impl Eq for Group
impl StructuralPartialEq for Group
Auto Trait Implementations§
impl Freeze for Group
impl !RefUnwindSafe for Group
impl !Send for Group
impl !Sync for Group
impl Unpin for Group
impl !UnwindSafe for Group
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more