Skip to main content

Configurable

Trait Configurable 

Source
pub trait Configurable {
    type Partial: PartialValue<Resolved = Self>;
    type Node: PartialValue + Default + EffectivelyUnset + Merge + Serialize + for<'a> Deserialize<'a>;
}
Expand description

Relates a configuration type to how it is represented while a configuration is still being loaded.

This is what lets every field of a partial struct be written the same way, as <FieldType as Configurable>::Node, without knowing whether the field holds an atomic value or a nested struct: the type itself answers that.

Required Associated Types§

Source

type Partial: PartialValue<Resolved = Self>

How this type is represented before defaults are applied.

Source

type Node: PartialValue + Default + EffectivelyUnset + Merge + Serialize + for<'a> Deserialize<'a>

How a field of this type is stored in the partial struct holding it. Atomic values are stored in a Setting, nested structs in a Section.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Configurable for f32

Source§

type Partial = PartialF32

Source§

type Node = Setting<PartialF32>

Source§

impl Configurable for f64

Source§

type Partial = PartialF64

Source§

type Node = Setting<PartialF64>

Source§

impl<T> Configurable for Vec<T>
where T: Configurable, <T as Configurable>::Partial: Serialize + for<'a> Deserialize<'a>,

A vector is atomic for merging, so it is stored in a single setting, while its elements stay partial so that they can be defaulted individually.

Implementors§

Source§

impl<T> Configurable for T

An atomic value is its own partial representation, and a field holding one is a setting.