Skip to main content

RdmCollection

Struct RdmCollection 

Source
pub struct RdmCollection {
    pub id: String,
    pub name: Option<String>,
    /* private fields */
}
Expand description

A collection of RDM concepts

Fields§

§id: String

Collection ID

§name: Option<String>

Collection name (optional, for display)

Implementations§

Source§

impl RdmCollection

Source

pub fn new(id: String) -> Self

Source

pub fn with_name(id: String, name: String) -> Self

Create a new collection with a name

Source

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.

Source

pub fn get_top_concepts(&self) -> Vec<&RdmConcept>

Get top-level concepts (no broader)

Source

pub fn get_concept(&self, concept_id: &str) -> Option<&RdmConcept>

Get a concept by ID

Source

pub fn get_concept_mut(&mut self, concept_id: &str) -> Option<&mut RdmConcept>

Get a mutable concept by ID

Source

pub fn get_label(&self, concept_id: &str, language: &str) -> Option<String>

Get the label for a concept in this collection

Source

pub fn from_concepts_json(id: String, json: &str) -> Result<Self, String>

Parse collection from JSON array of concepts

Source

pub fn len(&self) -> usize

Get the number of concepts in this collection

Source

pub fn is_empty(&self) -> bool

Check if the collection is empty

Source

pub fn has_concept(&self, concept_id: &str) -> bool

Check if a concept exists in the collection

Source

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

Get all concept IDs

Source

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.

Source

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.

Source

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.

Source

pub fn has_value(&self, value_id: &str) -> bool

Check if a value ID exists in this collection

Source

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

Get all value IDs in this collection

Source

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.

Source

pub fn find_all_by_label(&self, label: &str) -> Vec<&RdmConcept>

Find all concepts by exact label match (case-insensitive)

Source

pub fn search(&self, query: &str, language: Option<&str>) -> Vec<&RdmConcept>

Search concepts by label prefix (case-insensitive)

Trait Implementations§

Source§

impl Clone for RdmCollection

Source§

fn clone(&self) -> RdmCollection

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 RdmCollection

Source§

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

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

impl Default for RdmCollection

Source§

fn default() -> RdmCollection

Returns the “default value” for a type. 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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.