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: TThe effective value.
provenance: ProvenanceWhether an input set value, or it is a default.
Implementations§
Source§impl<T> ConfigValue<T>
impl<T> ConfigValue<T>
Sourcepub fn new(value: T, provenance: Provenance) -> Self
pub fn new(value: T, provenance: Provenance) -> Self
Creates a value with the given provenance.
Sourcepub fn is_explicit(&self) -> bool
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>
impl<T: Clone> Clone for ConfigValue<T>
Source§fn clone(&self) -> ConfigValue<T>
fn clone(&self) -> ConfigValue<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more