pub struct ControlRegistry { /* private fields */ }Expand description
Holds every control declared on one component. Lookup by
name is typed via Self::get::<T>; enumeration returns
erased handles so callers can render / inspect without
knowing T.
Implementations§
Source§impl ControlRegistry
impl ControlRegistry
pub fn new() -> Self
Sourcepub fn declare<T>(&self, control: Control<T>)
pub fn declare<T>(&self, control: Control<T>)
Register a control. Panics if a control by the same name already exists on this component — declaration is structural and name collisions are bugs.
Sourcepub fn get<T>(&self, name: &str) -> Option<Control<T>>
pub fn get<T>(&self, name: &str) -> Option<Control<T>>
Look up a control by name with a specific value type.
Returns None if the name doesn’t exist OR if the
caller’s T doesn’t match the registered type.
Sourcepub fn get_erased(&self, name: &str) -> Option<Arc<dyn ErasedControl>>
pub fn get_erased(&self, name: &str) -> Option<Arc<dyn ErasedControl>>
Erased access — returns the control’s metadata without
needing to know T. Used by discovery / enumeration.
Sourcepub fn list(&self) -> Vec<Arc<dyn ErasedControl>>
pub fn list(&self) -> Vec<Arc<dyn ErasedControl>>
Enumerate every declared control on this component. Order is unspecified.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn snapshot_gauges(
&self,
base_labels: &Labels,
captured_at: Instant,
) -> MetricSet
pub fn snapshot_gauges( &self, base_labels: &Labels, captured_at: Instant, ) -> MetricSet
Produce a MetricSet with two families per declared
control:
- Numeric gauge
control.<name>— emitted only when the control has a reified-gauge projection and the current value projects to a numericf64. Missing orNoneprojections skip this family. - Info family
control_info.<name>— emitted for every control regardless of numeric projection. Constant value1.0; the current value is carried on avalue="..."label so sinks that filter / group by dimensional labels can read the symbolic value directly. Follows the OpenMetrics “info” pattern (SRD 23 §“Non-numeric controls: info family”).
Enum / bool / string controls (no numeric projection) flow through the metrics pipeline via (2). Numeric controls get both families so reporters can query the running total as a number AND group by its textual form.
Called from crate::component::capture_tree at every
scheduler tick.