pub struct NestedFieldExtractor { /* private fields */ }Expand description
Extracts a potentially nested scalar field value using a pre-defined path.
This struct allows specifying a path as a sequence of field names.
It uses the FieldValueExtractorSerializer internally to traverse the structure.
Implementations§
Source§impl NestedFieldExtractor
impl NestedFieldExtractor
Sourcepub fn new_from_path<S: AsRef<str>>(
path_segments: &[S],
) -> Result<Self, EvaluateError>
pub fn new_from_path<S: AsRef<str>>( path_segments: &[S], ) -> Result<Self, EvaluateError>
Creates a new NestedFieldExtractor from a slice of path segments.
Each element in the input slice represents a step in the path.
§Arguments
path_segments: A slice where each element can be converted into a&str(e.g.,&str,String).
§Errors
Returns EvaluateError::InvalidPath if the input slice is empty or if any
segment converts to an empty string.
Sourcepub fn evaluate<T: Serialize>(
&self,
value: &T,
) -> Result<FieldScalarValue, EvaluateError>
pub fn evaluate<T: Serialize>( &self, value: &T, ) -> Result<FieldScalarValue, EvaluateError>
Evaluates the extractor against the given serializable value using the configured path.
This triggers the serialization process, traversing the nested structure according
to path_segments and intercepting the target field’s value.
§Arguments
value- A reference to a value that implementsserde::Serialize.
§Returns
Ok(FieldScalarValue)if the field at the specified path is found and is a supported scalar type.Err(EvaluateError)if the path is invalid, an intermediate field is not a struct, the final field is not found or has an unsupported type, or a serialization error occurs.
Trait Implementations§
Source§impl Clone for NestedFieldExtractor
impl Clone for NestedFieldExtractor
Source§fn clone(&self) -> NestedFieldExtractor
fn clone(&self) -> NestedFieldExtractor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for NestedFieldExtractor
impl RefUnwindSafe for NestedFieldExtractor
impl Send for NestedFieldExtractor
impl Sync for NestedFieldExtractor
impl Unpin for NestedFieldExtractor
impl UnwindSafe for NestedFieldExtractor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more