pub struct Tags { /* private fields */ }Expand description
A collection of tags with operations for add, remove, rename, query, and dedup.
Implementations§
Source§impl Tags
impl Tags
Sourcepub fn add(&mut self, tag: Tag)
pub fn add(&mut self, tag: Tag)
Add a tag. If a tag with the same name already exists, it is replaced.
Sourcepub fn dedup(&mut self)
pub fn dedup(&mut self)
Remove duplicate tags, keeping the first occurrence of each name (compared case-insensitively).
Sourcepub fn has(&self, name: &str) -> bool
pub fn has(&self, name: &str) -> bool
Check whether a tag with the given name exists (case-insensitive).
Sourcepub fn matches_wildcard(&self, pattern: &str) -> bool
pub fn matches_wildcard(&self, pattern: &str) -> bool
Check whether any tag name matches a wildcard pattern.
Wildcards: * matches zero or more characters, ? matches exactly one.
Matching is case-insensitive.
Sourcepub fn remove(&mut self, name: &str) -> usize
pub fn remove(&mut self, name: &str) -> usize
Remove all tags whose names match case-insensitively. Returns the number of tags removed.
Sourcepub fn remove_by_regex(&mut self, pattern: &str) -> usize
pub fn remove_by_regex(&mut self, pattern: &str) -> usize
Remove all tags whose names match a regex pattern (case-insensitive). Returns the number of tags removed.
Sourcepub fn remove_by_wildcard(&mut self, pattern: &str) -> usize
pub fn remove_by_wildcard(&mut self, pattern: &str) -> usize
Remove all tags whose names match a wildcard pattern. Returns the number of tags removed.
Sourcepub fn rename(&mut self, old_name: &str, new_name: &str) -> usize
pub fn rename(&mut self, old_name: &str, new_name: &str) -> usize
Rename all tags matching old_name to new_name, preserving values.
Returns the number of tags renamed.
Sourcepub fn rename_by_wildcard(&mut self, pattern: &str, new_name: &str) -> usize
pub fn rename_by_wildcard(&mut self, pattern: &str, new_name: &str) -> usize
Rename all tags matching a wildcard pattern to new_name, preserving
values. Returns the number of tags renamed.