pub struct RdmCollection {
pub id: String,
pub name: Option<String>,
/* private fields */
}Expand description
A collection of RDM concepts
Fields§
§id: StringCollection ID
name: Option<String>Collection name (optional, for display)
Implementations§
Source§impl RdmCollection
impl RdmCollection
pub fn new(id: String) -> Self
Sourcepub fn add_concept(&mut self, concept: RdmConcept)
pub fn add_concept(&mut self, concept: RdmConcept)
Add a concept to the collection
This also builds the value index for all labels in the concept. If a label has a placeholder ID (“pending”), a deterministic ID is generated.
Sourcepub fn get_top_concepts(&self) -> Vec<&RdmConcept>
pub fn get_top_concepts(&self) -> Vec<&RdmConcept>
Get top-level concepts (no broader)
Sourcepub fn get_concept(&self, concept_id: &str) -> Option<&RdmConcept>
pub fn get_concept(&self, concept_id: &str) -> Option<&RdmConcept>
Get a concept by ID
Sourcepub fn get_concept_mut(&mut self, concept_id: &str) -> Option<&mut RdmConcept>
pub fn get_concept_mut(&mut self, concept_id: &str) -> Option<&mut RdmConcept>
Get a mutable concept by ID
Sourcepub fn get_label(&self, concept_id: &str, language: &str) -> Option<String>
pub fn get_label(&self, concept_id: &str, language: &str) -> Option<String>
Get the label for a concept in this collection
Sourcepub fn from_concepts_json(id: String, json: &str) -> Result<Self, String>
pub fn from_concepts_json(id: String, json: &str) -> Result<Self, String>
Parse collection from JSON array of concepts
Sourcepub fn has_concept(&self, concept_id: &str) -> bool
pub fn has_concept(&self, concept_id: &str) -> bool
Check if a concept exists in the collection
Sourcepub fn get_concept_ids(&self) -> Vec<&String>
pub fn get_concept_ids(&self) -> Vec<&String>
Get all concept IDs
Sourcepub fn get_parent_id(&self, concept_id: &str) -> Option<String>
pub fn get_parent_id(&self, concept_id: &str) -> Option<String>
Get the first parent ID for a concept (from broader field)
Returns None if the concept doesn’t exist or has no parent (top-level concept). SKOS concepts can have multiple parents; this returns only the first one.
Sourcepub fn get_value_by_id(&self, value_id: &str) -> Option<&RdmValue>
pub fn get_value_by_id(&self, value_id: &str) -> Option<&RdmValue>
Look up a value by its VALUE ID
This is the primary lookup method used by ViewModels. Returns None if the value ID is not found in this collection.
Sourcepub fn get_concept_id_for_value(&self, value_id: &str) -> Option<&str>
pub fn get_concept_id_for_value(&self, value_id: &str) -> Option<&str>
Get concept ID from value ID
Returns the concept ID that contains the given value ID.
Sourcepub fn get_value_ids(&self) -> Vec<&String>
pub fn get_value_ids(&self) -> Vec<&String>
Get all value IDs in this collection
Sourcepub fn find_by_label(&self, label: &str) -> Option<&RdmConcept>
pub fn find_by_label(&self, label: &str) -> Option<&RdmConcept>
Find a concept by exact label match (case-insensitive)
Searches pref_label and alt_labels across all languages. Returns the first match if found. When multiple concepts share the same label (common in hierarchical collections like administrative areas), a deterministic result is returned by selecting the concept with the lexicographically smallest ID.
Sourcepub fn find_all_by_label(&self, label: &str) -> Vec<&RdmConcept>
pub fn find_all_by_label(&self, label: &str) -> Vec<&RdmConcept>
Find all concepts by exact label match (case-insensitive)
Trait Implementations§
Source§impl Clone for RdmCollection
impl Clone for RdmCollection
Source§fn clone(&self) -> RdmCollection
fn clone(&self) -> RdmCollection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more