Skip to main content

Control

Struct Control 

Source
pub struct Control<T: Clone + Send + Sync + 'static> { /* private fields */ }

Implementations§

Source§

impl<T: Clone + Send + Sync + 'static> Control<T>

Source

pub fn name(&self) -> &str

Name of this control within its owning component’s registry.

Source

pub fn get(&self) -> Versioned<T>

Borrow the current committed value.

Source

pub fn value(&self) -> T

Convenience shortcut for self.get().value when the caller doesn’t need the metadata.

Source

pub fn register_applier<A>(&self, applier: A) -> usize
where 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.

Source

pub fn applier_count(&self) -> usize

Number of currently-registered appliers.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn branch_scope(&self) -> BranchScope

Declared branch scope of this control.

Trait Implementations§

Source§

impl<T: Clone + Send + Sync + 'static> Clone for Control<T>

Source§

fn clone(&self) -> Self

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<T> ErasedControl for Control<T>
where T: Clone + Send + Sync + Debug + 'static,

Source§

fn name(&self) -> &str

Source§

fn rev(&self) -> u64

Source§

fn origin(&self) -> ControlOrigin

Source§

fn applier_count(&self) -> usize

Source§

fn value_string(&self) -> String

Human-readable rendering of the current value, for diagnostics / dryrun=controls output.
Source§

fn value_type_name(&self) -> &'static str

Static type name of T — stable enough to hint the caller what concrete type they’d need to downcast to.
Source§

fn gauge_f64(&self) -> Option<f64>

The reified gauge value (if the control opted in), for the registry’s MetricSet snapshot. None means either no reification or the current value has no numeric projection right now.
Source§

fn has_reified_gauge(&self) -> bool

True if the control was declared with gauge reification.
Source§

fn is_final(&self) -> bool

True if the control was declared final. Final controls reject every non-Launch write.
Source§

fn final_scope(&self) -> Option<String>

Scope name carried by a final declaration, if any.
Source§

fn branch_scope(&self) -> BranchScope

Declared branch scope of this control.
Source§

fn accepts_f64_writes(&self) -> bool

true if the control opts into f64-routed writes via ControlBuilder::from_f64.
Source§

fn set_f64( &self, value: f64, origin: ControlOrigin, ) -> Pin<Box<dyn Future<Output = Result<u64, SetError>> + Send>>

Type-erased write through the 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.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Control<T>

§

impl<T> !UnwindSafe for Control<T>

§

impl<T> Freeze for Control<T>
where Arc<ControlInner<T>>: Freeze,

§

impl<T> Send for Control<T>
where Arc<ControlInner<T>>: Send,

§

impl<T> Sync for Control<T>
where Arc<ControlInner<T>>: Sync,

§

impl<T> Unpin for Control<T>
where Arc<ControlInner<T>>: Unpin,

§

impl<T> UnsafeUnpin for Control<T>
where Arc<ControlInner<T>>: UnsafeUnpin,

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

Source§

type Output = T

Should always be Self
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 = !

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.