pub struct KeywordCollection { /* private fields */ }Expand description
A collection of keyword instances on a card.
Mirrors Java’s KeywordCollection which uses a Multimap<Keyword, KeywordInterface>.
Serializes as a Vec<String> of original keyword strings for backward compatibility.
Implementations§
Source§impl KeywordCollection
impl KeywordCollection
Sourcepub fn from_strings(strings: &[String]) -> Self
pub fn from_strings(strings: &[String]) -> Self
Build a KeywordCollection from a Vec<String>.
Sourcepub fn contains_keyword(&self, keyword: Keyword) -> bool
pub fn contains_keyword(&self, keyword: Keyword) -> bool
Whether the collection contains any instance of the given keyword.
Sourcepub fn get_amount(&self, keyword: Keyword) -> i32
pub fn get_amount(&self, keyword: Keyword) -> i32
Get the total amount for a keyword (sum of all instances).
Sourcepub fn insert(&mut self, inst: KeywordInstanceData) -> bool
pub fn insert(&mut self, inst: KeywordInstanceData) -> bool
Insert a keyword instance data. Returns true if it was added.
Sourcepub fn add(&mut self, k: &str) -> bool
pub fn add(&mut self, k: &str) -> bool
Add a keyword from a string, parsing it into the appropriate type.
Sourcepub fn add_all<'a>(&mut self, keywords: impl IntoIterator<Item = &'a str>)
pub fn add_all<'a>(&mut self, keywords: impl IntoIterator<Item = &'a str>)
Add all keywords from string iterator.
Sourcepub fn remove(&mut self, keyword: &str) -> bool
pub fn remove(&mut self, keyword: &str) -> bool
Remove all instances whose original string starts with the given prefix.
Sourcepub fn remove_all(&mut self, keyword: Keyword) -> bool
pub fn remove_all(&mut self, keyword: Keyword) -> bool
Remove all instances of a keyword enum variant.
Sourcepub fn remove_strings<'a>(
&mut self,
keywords: impl IntoIterator<Item = &'a str>,
) -> bool
pub fn remove_strings<'a>( &mut self, keywords: impl IntoIterator<Item = &'a str>, ) -> bool
Remove keywords matching any of the given strings.
Sourcepub fn contains_string(&self, keyword: &str) -> bool
pub fn contains_string(&self, keyword: &str) -> bool
Check if collection contains a keyword by exact original string match.
Sourcepub fn contains_string_ignore_case(&self, keyword: &str) -> bool
pub fn contains_string_ignore_case(&self, keyword: &str) -> bool
Check if collection contains a keyword by case-insensitive original string match.
Sourcepub fn any_starts_with(&self, prefix: &str) -> bool
pub fn any_starts_with(&self, prefix: &str) -> bool
Check if any keyword’s original string starts with the given prefix.
Sourcepub fn any_starts_with_ignore_case(&self, prefix: &str) -> bool
pub fn any_starts_with_ignore_case(&self, prefix: &str) -> bool
Check if any keyword’s original string starts with the given prefix (case-insensitive).
Sourcepub fn find_with_prefix(&self, prefix: &str) -> Option<&str>
pub fn find_with_prefix(&self, prefix: &str) -> Option<&str>
Find the first keyword whose original string starts with the given prefix.
Sourcepub fn iter_strings(&self) -> impl Iterator<Item = &str>
pub fn iter_strings(&self) -> impl Iterator<Item = &str>
Iterate over original keyword strings.
Sourcepub fn retain<F: Fn(&str) -> bool>(&mut self, f: F)
pub fn retain<F: Fn(&str) -> bool>(&mut self, f: F)
Retain only keywords matching a predicate on the original string.
Sourcepub fn extend(&mut self, other: impl IntoIterator<Item = String>)
pub fn extend(&mut self, other: impl IntoIterator<Item = String>)
Extend this collection with keywords from another collection.
Sourcepub fn get_values(&self) -> Vec<&KeywordInstanceData>
pub fn get_values(&self) -> Vec<&KeywordInstanceData>
Get all keyword instance data as a flat list.
Sourcepub fn get_values_for(&self, keyword: Keyword) -> Vec<&KeywordInstanceData>
pub fn get_values_for(&self, keyword: Keyword) -> Vec<&KeywordInstanceData>
Get all keyword instances for a specific keyword.
Sourcepub fn contains(&self, keyword: &str) -> bool
pub fn contains(&self, keyword: &str) -> bool
Check if the collection contains a keyword by string prefix match.
Mirrors Java’s KeywordCollection.contains(String).
Sourcepub fn insert_all(&mut self, keywords: &[KeywordInstanceData])
pub fn insert_all(&mut self, keywords: &[KeywordInstanceData])
Insert all keyword instance data from a slice.
Mirrors Java’s KeywordCollection.insertAll(Iterable<KeywordInterface>).
Sourcepub fn remove_instances(&mut self, keyword: &str)
pub fn remove_instances(&mut self, keyword: &str)
Remove all instances of a specific keyword string (exact match).
Mirrors Java’s KeywordCollection.removeInstances(Keyword, String).
Sourcepub fn apply_changes(&mut self, additions: &[String], removals: &[String])
pub fn apply_changes(&mut self, additions: &[String], removals: &[String])
Apply a batch of keyword additions and removals.
Mirrors Java’s KeywordCollection.applyChanges(KeywordsChange).
Sourcepub fn iterator(&self) -> impl Iterator<Item = &str>
pub fn iterator(&self) -> impl Iterator<Item = &str>
Iterate over keyword strings. Alias for iter_strings for parity
with Java’s KeywordCollection.iterator().
Sourcepub fn as_string_list(&self) -> Vec<String>
pub fn as_string_list(&self) -> Vec<String>
Get all keywords as a list of original strings.
Trait Implementations§
Source§impl Clone for KeywordCollection
impl Clone for KeywordCollection
Source§fn clone(&self) -> KeywordCollection
fn clone(&self) -> KeywordCollection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more