pub trait IntoEvaluationResult {
// Required method
fn to_evaluation_result(&self) -> EvaluationResult;
}Expand description
Universal conversion trait for transforming values into FHIRPath evaluation results.
This trait provides the bridge between FHIR data types and the FHIRPath evaluation
system. It allows any type to be converted into an EvaluationResult that can be
processed by FHIRPath expressions.
§Implementation Guidelines
When implementing this trait:
- Return
EvaluationResult::EmptyforNoneor missing values - Use appropriate variant types (Boolean, String, Integer, etc.)
- For complex types, use
EvaluationResult::Objectwith field mappings - For arrays/collections, use
EvaluationResult::Collection
§Examples
use helios_fhirpath_support::{EvaluationResult, IntoEvaluationResult};
struct CustomType {
value: String,
active: bool,
}
impl IntoEvaluationResult for CustomType {
fn to_evaluation_result(&self) -> EvaluationResult {
let mut map = std::collections::HashMap::new();
map.insert("value".to_string(), self.value.to_evaluation_result());
map.insert("active".to_string(), self.active.to_evaluation_result());
EvaluationResult::Object { map, type_info: None }
}
}Required Methods§
Sourcefn to_evaluation_result(&self) -> EvaluationResult
fn to_evaluation_result(&self) -> EvaluationResult
Converts this value into a FHIRPath evaluation result.
This method should transform the implementing type into the most appropriate
EvaluationResult variant that represents the value’s semantics in FHIRPath.
Implementations on Foreign Types§
Source§impl IntoEvaluationResult for bool
Converts a bool to EvaluationResult::Boolean.
impl IntoEvaluationResult for bool
Converts a bool to EvaluationResult::Boolean.
Enables direct use of Rust boolean values in FHIRPath expressions.
fn to_evaluation_result(&self) -> EvaluationResult
Source§impl IntoEvaluationResult for f64
Converts an f64 to EvaluationResult::Decimal with error handling.
impl IntoEvaluationResult for f64
Converts an f64 to EvaluationResult::Decimal with error handling.
Uses high-precision Decimal type to avoid floating-point errors.
Returns Empty for invalid values like NaN or Infinity.
fn to_evaluation_result(&self) -> EvaluationResult
Source§impl IntoEvaluationResult for i32
Converts an i32 to EvaluationResult::Integer.
impl IntoEvaluationResult for i32
Converts an i32 to EvaluationResult::Integer.
Automatically promotes to i64 for consistent integer handling.
fn to_evaluation_result(&self) -> EvaluationResult
Source§impl IntoEvaluationResult for i64
Converts an i64 to EvaluationResult::Integer.
impl IntoEvaluationResult for i64
Converts an i64 to EvaluationResult::Integer.
This is the primary integer type used in FHIRPath evaluation.
fn to_evaluation_result(&self) -> EvaluationResult
Source§impl IntoEvaluationResult for String
Converts a String to EvaluationResult::String.
impl IntoEvaluationResult for String
Converts a String to EvaluationResult::String.
This is the most direct conversion for text values in the FHIRPath system.
fn to_evaluation_result(&self) -> EvaluationResult
Source§impl IntoEvaluationResult for Decimal
Converts a rust_decimal::Decimal to EvaluationResult::Decimal.
impl IntoEvaluationResult for Decimal
Converts a rust_decimal::Decimal to EvaluationResult::Decimal.
This is the preferred conversion for precise decimal values in FHIR.
fn to_evaluation_result(&self) -> EvaluationResult
Source§impl<T> IntoEvaluationResult for Option<T>where
T: IntoEvaluationResult,
Converts Option<T> to either the inner value’s result or Empty.
impl<T> IntoEvaluationResult for Option<T>where
T: IntoEvaluationResult,
Converts Option<T> to either the inner value’s result or Empty.
This is fundamental for handling FHIR’s optional fields and nullable values.
Some(value) converts the inner value, None becomes Empty.
fn to_evaluation_result(&self) -> EvaluationResult
Source§impl<T> IntoEvaluationResult for Box<T>where
T: IntoEvaluationResult + ?Sized,
Converts Box<T> to the result of the boxed value.
impl<T> IntoEvaluationResult for Box<T>where
T: IntoEvaluationResult + ?Sized,
Converts Box<T> to the result of the boxed value.
This enables use of boxed values (often used to break circular references in FHIR data structures) directly in FHIRPath evaluation.
fn to_evaluation_result(&self) -> EvaluationResult
Source§impl<T> IntoEvaluationResult for Vec<T>where
T: IntoEvaluationResult,
Converts Vec<T> to EvaluationResult::Collection.
impl<T> IntoEvaluationResult for Vec<T>where
T: IntoEvaluationResult,
Converts Vec<T> to EvaluationResult::Collection.
Each item in the vector is converted to an EvaluationResult. The resulting
collection is marked as having defined order (FHIRPath collections maintain order).