pub struct Configuration { /* private fields */ }Expand description
One possible “shape” the flattened type could take.
Represents a specific choice of variants for all enums in the flatten tree.
Implementations§
Source§impl Configuration
impl Configuration
Sourcepub fn matches(&self, input_fields: &BTreeSet<&str>) -> MatchResult
pub fn matches(&self, input_fields: &BTreeSet<&str>) -> MatchResult
Check if this configuration matches the input fields.
Sourcepub fn describe(&self) -> String
pub fn describe(&self) -> String
Get a human-readable description of this configuration.
Returns something like MessagePayload::Text or Auth::Token + Transport::Tcp
for configurations with multiple variant selections.
Sourcepub fn deserialization_order(&self) -> Vec<&FieldInfo>
pub fn deserialization_order(&self) -> Vec<&FieldInfo>
Get the fields in deserialization order (deepest first).
Sourcepub fn missing_optional_fields<'a>(
&'a self,
seen_keys: &'a BTreeSet<&str>,
) -> impl Iterator<Item = &'a FieldInfo>
pub fn missing_optional_fields<'a>( &'a self, seen_keys: &'a BTreeSet<&str>, ) -> impl Iterator<Item = &'a FieldInfo>
Get optional fields that were NOT provided in the input.
This is useful for deserializers that need to initialize missing
optional fields to None or their default value.
§Example
#[derive(Facet)]
struct Config {
required_field: String,
optional_field: Option<u32>,
}
let schema = Schema::build(Config::SHAPE).unwrap();
let config = &schema.configurations()[0];
// If we only saw "required_field"
let mut seen = BTreeSet::new();
seen.insert("required_field");
let missing: Vec<_> = config.missing_optional_fields(&seen).collect();
assert_eq!(missing.len(), 1);
assert_eq!(missing[0].serialized_name, "optional_field");Sourcepub fn variant_selections(&self) -> &[VariantSelection]
pub fn variant_selections(&self) -> &[VariantSelection]
Get variant selections.
Sourcepub fn known_paths(&self) -> &BTreeSet<KeyPath>
pub fn known_paths(&self) -> &BTreeSet<KeyPath>
Get all known key paths (for depth-aware probing).
Sourcepub fn has_key_path(&self, path: &[&str]) -> bool
pub fn has_key_path(&self, path: &[&str]) -> bool
Check if this configuration has a specific key path. Compares runtime strings against static schema paths.
Trait Implementations§
Source§impl Clone for Configuration
impl Clone for Configuration
Source§fn clone(&self) -> Configuration
fn clone(&self) -> Configuration
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more