ConfigValue

Struct ConfigValue 

Source
pub struct ConfigValue<T> {
    pub value: T,
    pub provenance: Provenance,
}
Expand description

A configuration value together with the reason it holds that value.

Most model fields are plain values, because their effective value is all a consumer needs. Use ConfigValue<T> for a setting whose behavior depends on whether the value was set explicitly, rather than on the value alone. The primary intake URL is the canonical example: the Core Agent supplies dd_url at its schema default even when the operator configured only site, so the URL alone cannot say whether it should override site.

The value and its provenance are independent, and both are always available. A defaulted setting holds its default value with Provenance::Default, rather than holding no value, so a consumer never has to restate a default the configuration layer already resolved:

if endpoints.dd_url.is_explicit() {
    resolve_verbatim(&endpoints.dd_url.value)
} else {
    resolve_from_site(&endpoints.site.value)
}

Equality covers both fields: a value that keeps its contents but becomes explicit is a change, and a Live view of it wakes.

Serialization emits the value alone, so the shape of a serialized SalukiConfiguration does not depend on which fields track provenance.

Prefer ConfigValue<T> over ConfigValue<Option<T>>. Reaching for the inner Option usually means it is duplicating the provenance: a T with Provenance::Default already expresses “no one configured this”, and the nested form leaves two different ways to say so.

Fields§

§value: T

The effective value.

§provenance: Provenance

Whether an input set value, or it is a default.

Implementations§

Source§

impl<T> ConfigValue<T>

Source

pub fn new(value: T, provenance: Provenance) -> Self

Creates a value with the given provenance.

Source

pub fn explicit(value: T) -> Self

Creates a value that an input set explicitly.

Source

pub fn defaulted(value: T) -> Self

Creates a default value that nothing set.

Source

pub fn is_explicit(&self) -> bool

Returns whether an input set this value explicitly.

A setting that acts as an override is in force only when this is true: a defaulted value expresses no intent to override anything.

Trait Implementations§

Source§

impl<T: Clone> Clone for ConfigValue<T>

Source§

fn clone(&self) -> ConfigValue<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for ConfigValue<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for ConfigValue<T>

Source§

fn default() -> ConfigValue<T>

Returns the “default value” for a type. Read more
Source§

impl<T: PartialEq> PartialEq for ConfigValue<T>

Source§

fn eq(&self, other: &ConfigValue<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Serialize> Serialize for ConfigValue<T>

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: Copy> Copy for ConfigValue<T>

Source§

impl<T: Eq> Eq for ConfigValue<T>

Source§

impl<T> StructuralPartialEq for ConfigValue<T>

Auto Trait Implementations§

§

impl<T> Freeze for ConfigValue<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for ConfigValue<T>
where T: RefUnwindSafe,

§

impl<T> Send for ConfigValue<T>
where T: Send,

§

impl<T> Sync for ConfigValue<T>
where T: Sync,

§

impl<T> Unpin for ConfigValue<T>
where T: Unpin,

§

impl<T> UnwindSafe for ConfigValue<T>
where T: UnwindSafe,

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<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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.