pub struct FieldResolver { /* private fields */ }Expand description
Resolves fixture field paths to language-specific accessor expressions.
Implementations§
Source§impl FieldResolver
impl FieldResolver
Sourcepub fn new(
fields: &HashMap<String, String>,
optional: &HashSet<String>,
result_fields: &HashSet<String>,
array_fields: &HashSet<String>,
method_calls: &HashSet<String>,
) -> Self
pub fn new( fields: &HashMap<String, String>, optional: &HashSet<String>, result_fields: &HashSet<String>, array_fields: &HashSet<String>, method_calls: &HashSet<String>, ) -> Self
Create a new resolver from the e2e config’s fields aliases,
fields_optional set, result_fields set, fields_array set,
and fields_method_calls set.
Sourcepub fn new_with_error_aliases(
fields: &HashMap<String, String>,
optional: &HashSet<String>,
result_fields: &HashSet<String>,
array_fields: &HashSet<String>,
method_calls: &HashSet<String>,
error_field_aliases: &HashMap<String, String>,
) -> Self
pub fn new_with_error_aliases( fields: &HashMap<String, String>, optional: &HashSet<String>, result_fields: &HashSet<String>, array_fields: &HashSet<String>, method_calls: &HashSet<String>, error_field_aliases: &HashMap<String, String>, ) -> Self
Create a new resolver that also includes error-path field aliases.
error_field_aliases maps fixture sub-field names (the part after "error.")
to the actual field names on the error type, enabling accessor_for_error to
resolve fields like "status_code" against the error value.
Sourcepub fn resolve<'a>(&'a self, fixture_field: &'a str) -> &'a str
pub fn resolve<'a>(&'a self, fixture_field: &'a str) -> &'a str
Resolve a fixture field path to the actual struct path. Falls back to the field itself if no alias exists.
Sourcepub fn is_optional(&self, field: &str) -> bool
pub fn is_optional(&self, field: &str) -> bool
Check if a resolved field path is optional.
Sourcepub fn has_alias(&self, fixture_field: &str) -> bool
pub fn has_alias(&self, fixture_field: &str) -> bool
Check if a fixture field has an explicit alias mapping.
Sourcepub fn is_valid_for_result(&self, fixture_field: &str) -> bool
pub fn is_valid_for_result(&self, fixture_field: &str) -> bool
Check whether a fixture field path is valid for the configured result type.
Sourcepub fn tagged_union_split(
&self,
fixture_field: &str,
) -> Option<(String, String, String)>
pub fn tagged_union_split( &self, fixture_field: &str, ) -> Option<(String, String, String)>
Check if a resolved field path traverses a tagged-union variant.
Returns Some((prefix, variant, suffix)) where:
prefixis the path up to (but not including) the tagged-union field (e.g.,"metadata.format")variantis the tagged-union accessor segment (e.g.,"excel")suffixis the remaining path after the variant (e.g.,"sheet_count")
Returns None if no tagged-union segment exists in the path.
Sourcepub fn has_map_access(&self, fixture_field: &str) -> bool
pub fn has_map_access(&self, fixture_field: &str) -> bool
Check if a resolved field path contains a non-numeric map access.
Sourcepub fn accessor(
&self,
fixture_field: &str,
language: &str,
result_var: &str,
) -> String
pub fn accessor( &self, fixture_field: &str, language: &str, result_var: &str, ) -> String
Generate a language-specific accessor expression.
Sourcepub fn accessor_for_error(
&self,
sub_field: &str,
language: &str,
err_var: &str,
) -> String
pub fn accessor_for_error( &self, sub_field: &str, language: &str, err_var: &str, ) -> String
Generate a language-specific accessor expression for an error-path field.
Used when assertion_type == "error" and the fixture declares a field
like "error.status_code". The caller strips the "error." prefix and
passes the sub-field name (e.g. "status_code") here.
Resolves against error_field_aliases (instead of the success-path
aliases). Falls back to direct field access (i.e. err_var.status_code)
when no alias exists.
For Rust, uses render_rust_with_optionals so that fields in
method_calls emit parentheses (e.g. err.status_code() when
"status_code" is in fields_method_calls).
Sourcepub fn has_error_aliases(&self) -> bool
pub fn has_error_aliases(&self) -> bool
Check whether a sub-field (the part after "error.") has an entry in
error_field_aliases or if there are any error aliases at all.
When there are no error aliases configured, callers fall back to
direct field access, which is the safe default for known public fields
like status_code on LiterLlmError.