Skip to main content

ControlRegistry

Struct ControlRegistry 

Source
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

Source

pub fn new() -> Self

Source

pub fn declare<T>(&self, control: Control<T>)
where T: Clone + Send + Sync + Debug + 'static,

Register a control. Panics if a control by the same name already exists on this component — declaration is structural and name collisions are bugs.

Source

pub fn get<T>(&self, name: &str) -> Option<Control<T>>
where T: Clone + Send + Sync + 'static,

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.

Source

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.

Source

pub fn list(&self) -> Vec<Arc<dyn ErasedControl>>

Enumerate every declared control on this component. Order is unspecified.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn snapshot_gauges( &self, base_labels: &Labels, captured_at: Instant, ) -> MetricSet

Produce a MetricSet with two families per declared control:

  1. Numeric gauge control.<name> — emitted only when the control has a reified-gauge projection and the current value projects to a numeric f64. Missing or None projections skip this family.
  2. Info family control_info.<name> — emitted for every control regardless of numeric projection. Constant value 1.0; the current value is carried on a value="..." 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.

Trait Implementations§

Source§

impl Default for ControlRegistry

Source§

fn default() -> Self

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.