Skip to main content

KeywordCollection

Struct KeywordCollection 

Source
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

Source

pub fn new() -> Self

Create a new empty keyword collection.

Source

pub fn from_strings(strings: &[String]) -> Self

Build a KeywordCollection from a Vec<String>.

Source

pub fn contains_keyword(&self, keyword: Keyword) -> bool

Whether the collection contains any instance of the given keyword.

Source

pub fn is_empty(&self) -> bool

Whether the collection is empty.

Source

pub fn size(&self) -> usize

Total number of keyword instances.

Source

pub fn get_amount(&self, keyword: Keyword) -> i32

Get the total amount for a keyword (sum of all instances).

Source

pub fn insert(&mut self, inst: KeywordInstanceData) -> bool

Insert a keyword instance data. Returns true if it was added.

Source

pub fn add(&mut self, k: &str) -> bool

Add a keyword from a string, parsing it into the appropriate type.

Source

pub fn add_all<'a>(&mut self, keywords: impl IntoIterator<Item = &'a str>)

Add all keywords from string iterator.

Source

pub fn remove(&mut self, keyword: &str) -> bool

Remove all instances whose original string starts with the given prefix.

Source

pub fn remove_all(&mut self, keyword: Keyword) -> bool

Remove all instances of a keyword enum variant.

Source

pub fn remove_strings<'a>( &mut self, keywords: impl IntoIterator<Item = &'a str>, ) -> bool

Remove keywords matching any of the given strings.

Source

pub fn clear(&mut self)

Clear all keywords.

Source

pub fn contains_string(&self, keyword: &str) -> bool

Check if collection contains a keyword by exact original string match.

Source

pub fn contains_string_ignore_case(&self, keyword: &str) -> bool

Check if collection contains a keyword by case-insensitive original string match.

Source

pub fn any_starts_with(&self, prefix: &str) -> bool

Check if any keyword’s original string starts with the given prefix.

Source

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).

Source

pub fn find_with_prefix(&self, prefix: &str) -> Option<&str>

Find the first keyword whose original string starts with the given prefix.

Source

pub fn iter_strings(&self) -> impl Iterator<Item = &str>

Iterate over original keyword strings.

Source

pub fn retain<F: Fn(&str) -> bool>(&mut self, f: F)

Retain only keywords matching a predicate on the original string.

Source

pub fn extend(&mut self, other: impl IntoIterator<Item = String>)

Extend this collection with keywords from another collection.

Source

pub fn get_values(&self) -> Vec<&KeywordInstanceData>

Get all keyword instance data as a flat list.

Source

pub fn get_values_for(&self, keyword: Keyword) -> Vec<&KeywordInstanceData>

Get all keyword instances for a specific keyword.

Source

pub fn contains(&self, keyword: &str) -> bool

Check if the collection contains a keyword by string prefix match. Mirrors Java’s KeywordCollection.contains(String).

Source

pub fn insert_all(&mut self, keywords: &[KeywordInstanceData])

Insert all keyword instance data from a slice. Mirrors Java’s KeywordCollection.insertAll(Iterable<KeywordInterface>).

Source

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).

Source

pub fn apply_changes(&mut self, additions: &[String], removals: &[String])

Apply a batch of keyword additions and removals. Mirrors Java’s KeywordCollection.applyChanges(KeywordsChange).

Source

pub fn iterator(&self) -> impl Iterator<Item = &str>

Iterate over keyword strings. Alias for iter_strings for parity with Java’s KeywordCollection.iterator().

Source

pub fn as_string_list(&self) -> Vec<String>

Get all keywords as a list of original strings.

Trait Implementations§

Source§

impl Clone for KeywordCollection

Source§

fn clone(&self) -> KeywordCollection

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for KeywordCollection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for KeywordCollection

Source§

fn default() -> KeywordCollection

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for KeywordCollection

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for KeywordCollection

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V