Skip to main content

sim_lib_music_core/
citizen.rs

1use sim_kernel::{Expr, Symbol};
2
3use crate::MusicComponentDescriptor;
4
5/// Runtime citizen wrapper around a [`MusicComponentDescriptor`].
6///
7/// Pairs a component descriptor with the object surface the runtime expects,
8/// exposing it as a first-class music citizen.
9#[derive(Clone, Debug, PartialEq, Eq)]
10pub struct MusicComponentCitizenDescriptor {
11    descriptor: MusicComponentDescriptor,
12}
13
14impl MusicComponentCitizenDescriptor {
15    /// Wraps `descriptor` as a citizen descriptor.
16    pub fn new(descriptor: MusicComponentDescriptor) -> Self {
17        Self { descriptor }
18    }
19
20    /// Borrows the underlying component descriptor.
21    pub fn descriptor(&self) -> &MusicComponentDescriptor {
22        &self.descriptor
23    }
24
25    /// Renders the citizen as its descriptor expression.
26    pub fn as_expr(&self) -> Expr {
27        self.descriptor.to_expr()
28    }
29}
30
31/// Returns the class symbol for music component descriptors.
32pub fn music_component_descriptor_class_symbol() -> Symbol {
33    Symbol::qualified("music", "ComponentDescriptor")
34}
35
36/// Returns the class symbol for the music component registry.
37pub fn music_component_registry_class_symbol() -> Symbol {
38    Symbol::qualified("music", "ComponentRegistry")
39}
40
41/// Returns the class symbol for music component cards.
42pub fn music_component_card_class_symbol() -> Symbol {
43    Symbol::qualified("music", "ComponentCard")
44}