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>, ) -> Self

Create a new resolver from the e2e config’s fields aliases, fields_optional set, result_fields set, and fields_array set.

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.

When result_fields is non-empty, this returns true only if the first segment of the resolved field path appears in that set. When result_fields is empty (not configured), all fields are considered valid (backwards-compatible).

Source

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

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

Source

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

Check if a resolved field path ends with a map access (e.g., foo[key]). This is needed because Go map access returns a value type (not a pointer), so nil checks and pointer dereferences don’t apply.

Source

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

Generate a language-specific accessor expression. result_var is the variable holding the function return value.

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. Returns (binding_line, local_var_name) or None if the field is not optional.

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