pub struct Control<T: Clone + Send + Sync + 'static> { /* private fields */ }Implementations§
Source§impl<T: Clone + Send + Sync + 'static> Control<T>
impl<T: Clone + Send + Sync + 'static> Control<T>
Sourcepub fn value(&self) -> T
pub fn value(&self) -> T
Convenience shortcut for self.get().value when the
caller doesn’t need the metadata.
Sourcepub fn register_applier<A>(&self, applier: A) -> usizewhere
A: ControlApplier<T>,
pub fn register_applier<A>(&self, applier: A) -> usizewhere
A: ControlApplier<T>,
Register an applier. Every subsequent Self::set call
will include this applier in its fanout. There is no
unregister — appliers live for the control’s lifetime.
Returns the insertion index so callers can correlate
later failure reports.
Sourcepub fn applier_count(&self) -> usize
pub fn applier_count(&self) -> usize
Number of currently-registered appliers.
Sourcepub async fn set(
&self,
value: T,
origin: ControlOrigin,
) -> Result<u64, SetError>
pub async fn set( &self, value: T, origin: ControlOrigin, ) -> Result<u64, SetError>
Atomic write. Returns Ok(rev) with the new revision
only if every registered applier acknowledged the new
value within the control’s apply timeout. On any failure
the committed value is not advanced.
A control declared final via
ControlBuilder::final_at_scope rejects every write
whose origin is not ControlOrigin::Launch with
SetError::FinalViolation. The Launch-seed write
still goes through so the initial value can be
installed; runtime writers (CLI, TUI, GK, API) are
rejected against the pin.
Sourcepub fn gauge_f64(&self) -> Option<f64>
pub fn gauge_f64(&self) -> Option<f64>
Current reified-gauge value, if the control opted in via
ControlBuilder::reify_as_gauge and the conversion
returns Some. The registry snapshots this into a
MetricSet so control values flow through the normal
metric sinks.
Sourcepub fn reified_gauge(&self) -> Option<Arc<ValueGauge>>
pub fn reified_gauge(&self) -> Option<Arc<ValueGauge>>
Raw handle to the reified ValueGauge for callers that
want to sample the gauge directly without going through
the control machinery (e.g. registering it on a
crate::component::Component via
register_instrument). None if the control wasn’t
declared with gauge reification.
Sourcepub fn is_final(&self) -> bool
pub fn is_final(&self) -> bool
true if the control was declared final via
ControlBuilder::final_at_scope. Final controls
reject every non-Launch write.
Sourcepub fn final_scope(&self) -> Option<&str>
pub fn final_scope(&self) -> Option<&str>
Name of the scope at which the control was declared
final, if any. None for non-final controls.
Sourcepub fn branch_scope(&self) -> BranchScope
pub fn branch_scope(&self) -> BranchScope
Declared branch scope of this control.
Trait Implementations§
Source§impl<T> ErasedControl for Control<T>
impl<T> ErasedControl for Control<T>
fn name(&self) -> &str
fn rev(&self) -> u64
fn origin(&self) -> ControlOrigin
fn applier_count(&self) -> usize
Source§fn value_string(&self) -> String
fn value_string(&self) -> String
dryrun=controls output.Source§fn value_type_name(&self) -> &'static str
fn value_type_name(&self) -> &'static str
T — stable enough to hint the
caller what concrete type they’d need to downcast to.Source§fn gauge_f64(&self) -> Option<f64>
fn gauge_f64(&self) -> Option<f64>
None means either
no reification or the current value has no numeric
projection right now.Source§fn has_reified_gauge(&self) -> bool
fn has_reified_gauge(&self) -> bool
Source§fn is_final(&self) -> bool
fn is_final(&self) -> bool
final. Final
controls reject every non-Launch write.Source§fn final_scope(&self) -> Option<String>
fn final_scope(&self) -> Option<String>
Source§fn branch_scope(&self) -> BranchScope
fn branch_scope(&self) -> BranchScope
Source§fn accepts_f64_writes(&self) -> bool
fn accepts_f64_writes(&self) -> bool
Source§fn set_f64(
&self,
value: f64,
origin: ControlOrigin,
) -> Pin<Box<dyn Future<Output = Result<u64, SetError>> + Send>>
fn set_f64( &self, value: f64, origin: ControlOrigin, ) -> Pin<Box<dyn Future<Output = Result<u64, SetError>> + Send>>
f64 converter. Returns
the boxed async future so the caller can await from any
runtime. If the control didn’t register a converter the
future resolves to SetError::ValidationFailed with a
“no f64 setter registered” message.