pub struct EvaluationContext<'a> {
pub pruefidentifikator: &'a str,
pub external: &'a dyn ExternalConditionProvider,
pub segments: &'a [OwnedSegment],
pub navigator: Option<&'a dyn GroupNavigator>,
}Expand description
Context passed to condition evaluators during evaluation.
Carries references to the transaction data and external condition provider needed to evaluate AHB conditions.
Fields§
§pruefidentifikator: &'a strThe Pruefidentifikator (e.g., “11001”, “55001”) that identifies the specific AHB workflow being validated against.
external: &'a dyn ExternalConditionProviderProvider for external conditions that depend on business context outside the EDIFACT message.
segments: &'a [OwnedSegment]Parsed EDIFACT segments for direct segment inspection by condition evaluators. Conditions often need to check specific segment values.
Optional group navigator for group-scoped condition queries. When None, group-scoped methods return empty / false / 0.
Implementations§
Source§impl<'a> EvaluationContext<'a>
impl<'a> EvaluationContext<'a>
Sourcepub fn new(
pruefidentifikator: &'a str,
external: &'a dyn ExternalConditionProvider,
segments: &'a [OwnedSegment],
) -> Self
pub fn new( pruefidentifikator: &'a str, external: &'a dyn ExternalConditionProvider, segments: &'a [OwnedSegment], ) -> Self
Create a new evaluation context (without group navigator).
Create a new evaluation context with a group navigator.
Get the group navigator, if one is set.
Sourcepub fn find_segment(&self, segment_id: &str) -> Option<&'a OwnedSegment>
pub fn find_segment(&self, segment_id: &str) -> Option<&'a OwnedSegment>
Find the first segment with the given ID.
Sourcepub fn find_segments(&self, segment_id: &str) -> Vec<&'a OwnedSegment>
pub fn find_segments(&self, segment_id: &str) -> Vec<&'a OwnedSegment>
Find all segments with the given ID.
Sourcepub fn find_segments_with_qualifier(
&self,
segment_id: &str,
element_index: usize,
qualifier: &str,
) -> Vec<&'a OwnedSegment>
pub fn find_segments_with_qualifier( &self, segment_id: &str, element_index: usize, qualifier: &str, ) -> Vec<&'a OwnedSegment>
Find segments with a specific qualifier value on a given element.
Sourcepub fn has_segment(&self, segment_id: &str) -> bool
pub fn has_segment(&self, segment_id: &str) -> bool
Check if a segment with the given ID exists.
Sourcepub fn find_segments_in_group(
&self,
segment_id: &str,
group_path: &[&str],
instance_index: usize,
) -> Vec<OwnedSegment>
pub fn find_segments_in_group( &self, segment_id: &str, group_path: &[&str], instance_index: usize, ) -> Vec<OwnedSegment>
Find all segments with the given tag within a specific group instance. Returns empty if no navigator is set.
Sourcepub fn find_segments_with_qualifier_in_group(
&self,
segment_id: &str,
element_index: usize,
qualifier: &str,
group_path: &[&str],
instance_index: usize,
) -> Vec<OwnedSegment>
pub fn find_segments_with_qualifier_in_group( &self, segment_id: &str, element_index: usize, qualifier: &str, group_path: &[&str], instance_index: usize, ) -> Vec<OwnedSegment>
Find segments matching a tag + qualifier within a group instance. Returns empty if no navigator is set.
Sourcepub fn has_segment_in_group(
&self,
segment_id: &str,
group_path: &[&str],
instance_index: usize,
) -> bool
pub fn has_segment_in_group( &self, segment_id: &str, group_path: &[&str], instance_index: usize, ) -> bool
Check if a segment exists in a specific group instance. Returns false if no navigator is set.
Sourcepub fn group_instance_count(&self, group_path: &[&str]) -> usize
pub fn group_instance_count(&self, group_path: &[&str]) -> usize
Count repetitions of a group at the given path. Returns 0 if no navigator is set.
Sourcepub fn child_group_instance_count(
&self,
parent_path: &[&str],
parent_instance: usize,
child_group_id: &str,
) -> usize
pub fn child_group_instance_count( &self, parent_path: &[&str], parent_instance: usize, child_group_id: &str, ) -> usize
Count child group repetitions within a specific parent group instance. Returns 0 if no navigator is set.
Sourcepub fn find_segments_in_child_group(
&self,
segment_id: &str,
parent_path: &[&str],
parent_instance: usize,
child_group_id: &str,
child_instance: usize,
) -> Vec<OwnedSegment>
pub fn find_segments_in_child_group( &self, segment_id: &str, parent_path: &[&str], parent_instance: usize, child_group_id: &str, child_instance: usize, ) -> Vec<OwnedSegment>
Find segments in a child group within a specific parent group instance. Returns empty if no navigator is set.
Sourcepub fn extract_value_in_group(
&self,
segment_id: &str,
element_index: usize,
component_index: usize,
group_path: &[&str],
instance_index: usize,
) -> Option<String>
pub fn extract_value_in_group( &self, segment_id: &str, element_index: usize, component_index: usize, group_path: &[&str], instance_index: usize, ) -> Option<String>
Extract a single value from the first matching segment in a group instance. Returns None if no navigator is set or value not found.
Sourcepub fn has_qualifier(
&self,
tag: &str,
element_index: usize,
qualifier: &str,
) -> ConditionResult
pub fn has_qualifier( &self, tag: &str, element_index: usize, qualifier: &str, ) -> ConditionResult
Check if any segment with the given tag + qualifier exists (message-wide).
Returns True if found, False if not.
Sourcepub fn lacks_qualifier(
&self,
tag: &str,
element_index: usize,
qualifier: &str,
) -> ConditionResult
pub fn lacks_qualifier( &self, tag: &str, element_index: usize, qualifier: &str, ) -> ConditionResult
Check if a segment with given tag + qualifier does NOT exist (message-wide).
Returns True if absent, False if present.
Sourcepub fn has_qualified_value(
&self,
tag: &str,
qual_elem: usize,
qualifier: &str,
value_elem: usize,
value_comp: usize,
values: &[&str],
) -> ConditionResult
pub fn has_qualified_value( &self, tag: &str, qual_elem: usize, qualifier: &str, value_elem: usize, value_comp: usize, values: &[&str], ) -> ConditionResult
Check if any segment with the given tag + qualifier has a specific sub-element value.
Finds segments matching tag with elements[qual_elem][0] == qualifier,
then checks if elements[value_elem][value_comp] matches any of values.
Sourcepub fn any_group_has_qualifier(
&self,
tag: &str,
element_index: usize,
qualifier: &str,
group_path: &[&str],
) -> ConditionResult
pub fn any_group_has_qualifier( &self, tag: &str, element_index: usize, qualifier: &str, group_path: &[&str], ) -> ConditionResult
Group-scoped qualifier existence check with message-wide fallback.
Checks if any group instance at group_path contains a segment matching
tag with elements[element_index][0] == qualifier. Falls back to
message-wide search if no group navigator is available.
Sourcepub fn any_group_has_any_qualifier(
&self,
tag: &str,
element_index: usize,
qualifiers: &[&str],
group_path: &[&str],
) -> ConditionResult
pub fn any_group_has_any_qualifier( &self, tag: &str, element_index: usize, qualifiers: &[&str], group_path: &[&str], ) -> ConditionResult
Group-scoped segment existence check (any tag match, no qualifier).
Checks if any group instance at group_path contains a segment with
elements[element_index][0] matching any of qualifiers. Falls back
to message-wide search if no group navigator is available.
Sourcepub fn any_group_has_qualified_value(
&self,
tag: &str,
qual_elem: usize,
qualifier: &str,
value_elem: usize,
value_comp: usize,
values: &[&str],
group_path: &[&str],
) -> ConditionResult
pub fn any_group_has_qualified_value( &self, tag: &str, qual_elem: usize, qualifier: &str, value_elem: usize, value_comp: usize, values: &[&str], group_path: &[&str], ) -> ConditionResult
Group-scoped check for sub-element value within qualified segments.
For each group instance at group_path, checks if a segment matching
tag with elements[qual_elem][0] == qualifier has
elements[value_elem][value_comp] in values. Falls back to message-wide.
Sourcepub fn filtered_parent_child_has_qualifier(
&self,
parent_path: &[&str],
parent_tag: &str,
parent_elem: usize,
parent_qual: &str,
child_group_id: &str,
child_tag: &str,
child_elem: usize,
child_qual: &str,
) -> ConditionResult
pub fn filtered_parent_child_has_qualifier( &self, parent_path: &[&str], parent_tag: &str, parent_elem: usize, parent_qual: &str, child_group_id: &str, child_tag: &str, child_elem: usize, child_qual: &str, ) -> ConditionResult
Pattern A: Check if parent group instances matching a qualifier have a child group containing a specific qualifier.
Example: “In the SG8 with SEQ+Z98, does its SG10 child have CCI+Z23?”
Falls back to message-wide search if no navigator is available.
Sourcepub fn any_group_has_qualifier_without(
&self,
present_tag: &str,
present_elem: usize,
present_qual: &str,
absent_tag: &str,
absent_elem: usize,
absent_qual: &str,
group_path: &[&str],
) -> ConditionResult
pub fn any_group_has_qualifier_without( &self, present_tag: &str, present_elem: usize, present_qual: &str, absent_tag: &str, absent_elem: usize, absent_qual: &str, group_path: &[&str], ) -> ConditionResult
Pattern B: Check if any group instance has one qualifier present but another absent.
Example: “In any SG8, SEQ+Z59 is present but CCI+11 is absent”
Falls back to message-wide search if no navigator is available.
Sourcepub fn collect_group_values(
&self,
tag: &str,
elem: usize,
comp: usize,
group_path: &[&str],
) -> Vec<(usize, String)>
pub fn collect_group_values( &self, tag: &str, elem: usize, comp: usize, group_path: &[&str], ) -> Vec<(usize, String)>
Pattern C helper: Collect all values at a specific element+component across group instances.
Returns (instance_index, value) pairs for non-empty values.
Pattern C: Check if a value from one group path matches a value in another group path.
Example: “Zeitraum-ID in SG6 RFF+Z49 matches reference in SG8 SEQ.c286”
Finds qualified segments in source_path, extracts their value, then checks if any instance in target_path has the same value at the target position.
Falls back to message-wide search if no navigator is available.
Sourcepub fn any_group_has_co_occurrence(
&self,
tag_a: &str,
elem_a: usize,
quals_a: &[&str],
tag_b: &str,
elem_b: usize,
comp_b: usize,
vals_b: &[&str],
group_path: &[&str],
) -> ConditionResult
pub fn any_group_has_co_occurrence( &self, tag_a: &str, elem_a: usize, quals_a: &[&str], tag_b: &str, elem_b: usize, comp_b: usize, vals_b: &[&str], group_path: &[&str], ) -> ConditionResult
Group-scoped co-occurrence check: two segment conditions must both be true in the same group instance.
For each group instance, checks that:
- A segment with
tag_ahaselements[elem_a][0]inquals_a - A segment with
tag_bhaselements[elem_b][comp_b]invals_b
Falls back to message-wide search.
Sourcepub fn has_segment_matching(
&self,
tag: &str,
checks: &[(usize, usize, &str)],
) -> ConditionResult
pub fn has_segment_matching( &self, tag: &str, checks: &[(usize, usize, &str)], ) -> ConditionResult
Check if any segment with the given tag has ALL specified element/component values.
Each check is (element_index, component_index, expected_value).
Returns True if a matching segment exists, False if segments exist but none match,
Unknown if no segments with the tag exist.
Example: ctx.has_segment_matching("STS", &[(0, 0, "Z20"), (1, 0, "Z32"), (2, 0, "A99")])
Sourcepub fn has_segment_matching_in_group(
&self,
tag: &str,
checks: &[(usize, usize, &str)],
group_path: &[&str],
) -> ConditionResult
pub fn has_segment_matching_in_group( &self, tag: &str, checks: &[(usize, usize, &str)], group_path: &[&str], ) -> ConditionResult
Group-scoped multi-element match with message-wide fallback.
Checks if any group instance at group_path contains a segment with tag
where ALL element/component checks match.
Sourcepub fn dtm_ge(&self, qualifier: &str, threshold: &str) -> ConditionResult
pub fn dtm_ge(&self, qualifier: &str, threshold: &str) -> ConditionResult
Check if a DTM segment with the given qualifier has a value >= threshold.
Both the DTM value and threshold should be in EDIFACT format 303 (CCYYMMDDHHMM).
Returns Unknown if no DTM with the qualifier exists.
Sourcepub fn dtm_lt(&self, qualifier: &str, threshold: &str) -> ConditionResult
pub fn dtm_lt(&self, qualifier: &str, threshold: &str) -> ConditionResult
Check if a DTM segment with the given qualifier has a value < threshold.
Sourcepub fn dtm_le(&self, qualifier: &str, threshold: &str) -> ConditionResult
pub fn dtm_le(&self, qualifier: &str, threshold: &str) -> ConditionResult
Check if a DTM segment with the given qualifier has a value <= threshold.
Sourcepub fn count_qualified_in_group(
&self,
tag: &str,
element_index: usize,
qualifier: &str,
group_path: &[&str],
) -> usize
pub fn count_qualified_in_group( &self, tag: &str, element_index: usize, qualifier: &str, group_path: &[&str], ) -> usize
Count segments matching tag + qualifier within a group path (across all instances).
Returns the total count across all group instances. Falls back to message-wide count if no navigator.
Sourcepub fn count_in_group(&self, tag: &str, group_path: &[&str]) -> usize
pub fn count_in_group(&self, tag: &str, group_path: &[&str]) -> usize
Count segments matching tag (any qualifier) within a group path.