pub enum Setting<T> {
Unset,
Set {
value: T,
origin: Option<OriginId>,
},
}Expand description
An atomic merge boundary in the configuration tree.
A set setting also records where its value came from if it has been set. Because parsing logic does not understand origins, they are attached separately.
Variants§
Implementations§
Source§impl<T> Setting<T>
impl<T> Setting<T>
Sourcepub fn value_from(value: T, origin: OriginId) -> Self
pub fn value_from(value: T, origin: OriginId) -> Self
Create a set setting originating from origin.
Sourcepub fn default_to(&mut self, value: impl FnOnce() -> T)
pub fn default_to(&mut self, value: impl FnOnce() -> T)
Set this setting to its built-in default if no document supplied a value. The default is only produced when it is needed, so a setting a document supplied never pays for computing one it will not use.
Sourcepub fn into_option(self) -> Option<T>
pub fn into_option(self) -> Option<T>
Consume this setting, returning the value in it, if it is set.
Sourcepub fn require(self, path: &ConfigPath) -> Result<T, ConfigError>
pub fn require(self, path: &ConfigPath) -> Result<T, ConfigError>
Consume this setting, returning the value in it. If no value is set, returns an error naming the setting.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Setting<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Setting<T>where
T: Deserialize<'de>,
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl<T> Eq for Setting<T>where
T: Eq,
Source§impl<T> Merge for Setting<T>
A setting is a leaf node, so we don’t need to bother too much about merging.
impl<T> Merge for Setting<T>
A setting is a leaf node, so we don’t need to bother too much about merging.
fn merge( &mut self, incoming: Self, context: &mut MergeContext<'_>, ) -> Result<(), ConfigError>
Source§impl<T> PartialEq for Setting<T>where
T: PartialEq,
Two settings are equal when they carry equal values.
impl<T> PartialEq for Setting<T>where
T: PartialEq,
Two settings are equal when they carry equal values.
Source§impl<T> PartialValue for Setting<T>where
T: PartialValue,
impl<T> PartialValue for Setting<T>where
T: PartialValue,
Source§fn attribute(&mut self, origin: OriginId)
fn attribute(&mut self, origin: OriginId)
A setting records its own origin, and visits its nested values.
Source§fn apply_defaults(&mut self)
fn apply_defaults(&mut self)
A setting holds no default of its own, since the field it belongs to supplies that; it only lets nested values be defaulted. Note that if this setting itself should have been defaulted, that should have happened at the parent level.
Source§fn resolve(self, path: &mut ConfigPath) -> Result<Self::Resolved, ConfigError>
fn resolve(self, path: &mut ConfigPath) -> Result<Self::Resolved, ConfigError>
A setting resolves to whatever its value is, and is missing if no document and no default supplied one.
Source§type Resolved = <T as PartialValue>::Resolved
type Resolved = <T as PartialValue>::Resolved
Auto Trait Implementations§
impl<T> Forget for Setting<T>
impl<T> Freeze for Setting<T>where
T: Freeze,
impl<T> Move for Setting<T>
impl<T> RefUnwindSafe for Setting<T>where
T: RefUnwindSafe,
impl<T> Send for Setting<T>where
T: Send,
impl<T> Sync for Setting<T>where
T: Sync,
impl<T> Unpin for Setting<T>where
T: Unpin,
impl<T> UnsafeUnpin for Setting<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Setting<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.