pub struct Section {
pub name: String,
pub data: HashMap<String, String>,
}
Expand description
A Section to hold keynote file entries (key-value pairs)
Fields§
§name: String
name of the Section
data: HashMap<String, String>
hashmap to hold key value pairs that make up entries
Implementations§
Source§impl Section
impl Section
Sourcepub fn build_section_string(section_name: &str) -> String
pub fn build_section_string(section_name: &str) -> String
Sourcepub fn get_section_name_from_string(line: &str) -> Option<&str>
pub fn get_section_name_from_string(line: &str) -> Option<&str>
Returns name of a section from formatted section string. None if line is not valid section string;
§Arguments
line
- string slice containing section string
§Examples ///
use keydata::Section;
let line = "<test_section>\n";
let sn = Section::get_section_name_from_string(line);
assert!(sn.is_some());
assert_eq!(sn.unwrap(), "test_section");
Sourcepub fn add_entry(&mut self, key: &str, value: &str)
pub fn add_entry(&mut self, key: &str, value: &str)
Adds a key-value pair entry to the Sections data
§Arguments
key
- entry key as string slicevalue
- entry value as string slice
§Examples ///
use keydata::Section;
let mut s = Section::new("test_section");
assert_eq!(s.data.len(), 0);
s.add_entry("theKey", "theValue");
assert_eq!(s.data.len(), 1);
assert_eq!(s.data.get("theKey").unwrap(), "theValue");
Auto Trait Implementations§
impl Freeze for Section
impl RefUnwindSafe for Section
impl Send for Section
impl Sync for Section
impl Unpin for Section
impl UnwindSafe for Section
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