Skip to main content

FieldResolver

Struct FieldResolver 

Source
pub struct FieldResolver { /* private fields */ }
Expand description

Resolves fixture field paths to language-specific accessor expressions.

Implementations§

Source§

impl FieldResolver

Source

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.

Source

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.

Source

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.

Source

pub fn is_optional(&self, field: &str) -> bool

Check if a resolved field path is optional.

Source

pub fn has_alias(&self, fixture_field: &str) -> bool

Check if a fixture field has an explicit alias mapping.

Source

pub fn is_valid_for_result(&self, fixture_field: &str) -> bool

Check whether a fixture field path is valid for the configured result type.

Source

pub fn is_array(&self, field: &str) -> bool

Check if a resolved field is an array/Vec type.

Source

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:

  • prefix is the path up to (but not including) the tagged-union field (e.g., "metadata.format")
  • variant is the tagged-union accessor segment (e.g., "excel")
  • suffix is the remaining path after the variant (e.g., "sheet_count")

Returns None if no tagged-union segment exists in the path.

Source

pub fn has_map_access(&self, fixture_field: &str) -> bool

Check if a resolved field path contains a non-numeric map access.

Source

pub fn accessor( &self, fixture_field: &str, language: &str, result_var: &str, ) -> String

Generate a language-specific accessor expression.

Source

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).

Source

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.

Source

pub fn rust_unwrap_binding( &self, fixture_field: &str, result_var: &str, ) -> Option<(String, String)>

Generate a Rust variable binding that unwraps an Optional string field.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more