pub struct Resolution { /* 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. This is the “resolution” of all ambiguity in the type — all enum variants have been selected, all fields are known.
Implementations§
Source§impl Resolution
impl Resolution
Sourcepub const fn new() -> Resolution
pub const fn new() -> Resolution
Create a new empty resolution.
Sourcepub fn set_catch_all_map(&mut self, category: FieldCategory, info: FieldInfo)
pub fn set_catch_all_map(&mut self, category: FieldCategory, info: FieldInfo)
Set a catch-all map field for capturing unknown keys of a given category.
Sourcepub fn catch_all_map(&self, category: FieldCategory) -> Option<&FieldInfo>
pub fn catch_all_map(&self, category: FieldCategory) -> Option<&FieldInfo>
Get the catch-all map field for a given category, if any.
Sourcepub fn catch_all_maps(&self) -> &BTreeMap<FieldCategory, FieldInfo>
pub fn catch_all_maps(&self) -> &BTreeMap<FieldCategory, FieldInfo>
Get all catch-all maps.
Sourcepub fn add_key_path(&mut self, path: Vec<&'static str>)
pub fn add_key_path(&mut self, path: Vec<&'static str>)
Add a key path (for depth-aware probing, flat format).
Sourcepub fn add_dom_key_path(&mut self, path: Vec<FieldKey<'static>>)
pub fn add_dom_key_path(&mut self, path: Vec<FieldKey<'static>>)
Add a DOM key path (for depth-aware probing, DOM format).
Sourcepub fn add_field(&mut self, info: FieldInfo) -> Result<(), DuplicateFieldError>
pub fn add_field(&mut self, info: FieldInfo) -> Result<(), DuplicateFieldError>
Add a field to this resolution.
Returns an error if a field with the same key already exists but comes from a different source (different path). This catches duplicate field name conflicts between parent structs and flattened fields.
Sourcepub fn add_variant_selection(
&mut self,
path: FieldPath,
enum_name: &'static str,
variant_name: &'static str,
)
pub fn add_variant_selection( &mut self, path: FieldPath, enum_name: &'static str, variant_name: &'static str, )
Add a variant selection to this resolution.
Sourcepub fn merge(&mut self, other: &Resolution) -> Result<(), DuplicateFieldError>
pub fn merge(&mut self, other: &Resolution) -> Result<(), DuplicateFieldError>
Merge another resolution into this one.
Returns an error if a field with the same serialized name already exists but comes from a different source (different path). This catches duplicate field name conflicts between parent structs and flattened fields.
Sourcepub fn mark_all_optional(&mut self)
pub fn mark_all_optional(&mut self)
Mark all fields as optional (required = false).
Used when a flattened field is wrapped in Option<T>.
Sourcepub fn matches(&self, input_fields: &BTreeSet<Cow<'_, str>>) -> MatchResult
pub fn matches(&self, input_fields: &BTreeSet<Cow<'_, str>>) -> MatchResult
Check if this resolution matches the input fields.
Sourcepub fn describe(&self) -> String
pub fn describe(&self) -> String
Get a human-readable description of this resolution.
Returns something like MessagePayload::Text or Auth::Token + Transport::Tcp
for resolutions 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 field(&self, key: &FieldKey<'static>) -> Option<&FieldInfo>
pub fn field(&self, key: &FieldKey<'static>) -> Option<&FieldInfo>
Get a field by key.
For runtime keys, use field_by_key() which accepts any lifetime.
Sourcepub fn field_by_key(&self, key: &FieldKey<'_>) -> Option<&FieldInfo>
pub fn field_by_key(&self, key: &FieldKey<'_>) -> Option<&FieldInfo>
Get a field by key with any lifetime.
This is less efficient than field() because it searches linearly,
but works with runtime-constructed keys.
Sourcepub fn field_by_name(&self, name: &str) -> Option<&FieldInfo>
pub fn field_by_name(&self, name: &str) -> Option<&FieldInfo>
Get a field by name (flat format lookup).
For DOM format, use field() with a FieldKey instead.
Sourcepub const fn required_field_names(&self) -> &BTreeSet<&'static str>
pub const fn required_field_names(&self) -> &BTreeSet<&'static str>
Get the set of required field names.
Sourcepub fn missing_optional_fields<'a>(
&'a self,
seen_keys: &'a BTreeSet<Cow<'_, str>>,
) -> impl Iterator<Item = &'a FieldInfo>
pub fn missing_optional_fields<'a>( &'a self, seen_keys: &'a BTreeSet<Cow<'_, 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.
Sourcepub fn variant_selections(&self) -> &[VariantSelection]
pub fn variant_selections(&self) -> &[VariantSelection]
Get variant selections.
Sourcepub fn child_fields(&self) -> impl Iterator<Item = &FieldInfo>
pub fn child_fields(&self) -> impl Iterator<Item = &FieldInfo>
Get all child fields (fields with the CHILD flag).
This is useful for formats like XML where child elements need to be processed separately from attributes.
Sourcepub fn property_fields(&self) -> impl Iterator<Item = &FieldInfo>
pub fn property_fields(&self) -> impl Iterator<Item = &FieldInfo>
Get all property fields (fields without the child attribute).
This is useful for formats like XML where attributes are processed separately from child elements.
Sourcepub const fn known_paths(&self) -> &BTreeSet<Vec<&'static str>>
pub const fn known_paths(&self) -> &BTreeSet<Vec<&'static str>>
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 resolution has a specific key path (flat format).
Sourcepub fn has_dom_key_path(&self, path: &[FieldKey<'_>]) -> bool
pub fn has_dom_key_path(&self, path: &[FieldKey<'_>]) -> bool
Check if this resolution has a specific DOM key path.
Sourcepub const fn dom_known_paths(&self) -> &BTreeSet<Vec<FieldKey<'static>>>
pub const fn dom_known_paths(&self) -> &BTreeSet<Vec<FieldKey<'static>>>
Get all known DOM key paths (for depth-aware probing).
Trait Implementations§
Source§impl Clone for Resolution
impl Clone for Resolution
Source§fn clone(&self) -> Resolution
fn clone(&self) -> Resolution
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more