pub struct HDict { /* private fields */ }Expand description
Haystack Dict — the fundamental entity/row type in Haystack.
An HDict is a mutable dictionary mapping tag names (String) to values (Kind).
Dicts are used as rows in grids, as entity records, and as metadata containers.
Implementations§
Source§impl HDict
impl HDict
Create a dict from a pre-built HashMap.
Sourcepub fn has(&self, name: &str) -> bool
pub fn has(&self, name: &str) -> bool
Returns true if the dict contains a tag with the given name.
Sourcepub fn get(&self, name: &str) -> Option<&Kind>
pub fn get(&self, name: &str) -> Option<&Kind>
Returns a reference to the value for the given tag name, if present.
Sourcepub fn missing(&self, name: &str) -> bool
pub fn missing(&self, name: &str) -> bool
Returns true if the dict does NOT contain a tag with the given name.
Sourcepub fn dis(&self) -> Option<&str>
pub fn dis(&self) -> Option<&str>
Returns the display string for this dict.
Prefers the dis tag (if it is a Str), then falls back to the
id ref’s display name.
Sourcepub fn remove_tag(&mut self, name: &str) -> Option<Kind>
pub fn remove_tag(&mut self, name: &str) -> Option<Kind>
Remove a tag by name, returning its value if it was present.
Sourcepub fn merge(&mut self, other: &HDict)
pub fn merge(&mut self, other: &HDict)
Merge another dict into this one.
Tags from other overwrite tags in self. If a tag in other is
Kind::Remove, the corresponding tag in self is removed instead.
Returns a reference to the underlying HashMap.
Sourcepub fn sorted_iter(&self) -> Vec<(&str, &Kind)>
pub fn sorted_iter(&self) -> Vec<(&str, &Kind)>
Iterate over tags sorted by key name.
Sourcepub fn tag_name_set(&self) -> HashSet<&str>
pub fn tag_name_set(&self) -> HashSet<&str>
Collect all tag names into a HashSet.