mig_types/navigator.rs
1//! Group-scoped segment navigation trait.
2
3use crate::segment::OwnedSegment;
4
5/// Provides group-scoped segment access for condition evaluation.
6///
7/// Implementations translate hierarchical group paths (e.g., `["SG4", "SG8"]`)
8/// into segment lookups scoped to a specific group instance.
9pub trait GroupNavigator: Send + Sync {
10 /// Find all segments with the given tag within a specific group instance.
11 ///
12 /// * `segment_id` - Segment tag to find (e.g., "SEQ", "CCI")
13 /// * `group_path` - Path of group IDs from root (e.g., `&["SG4", "SG8"]`)
14 /// * `instance_index` - Which repetition of the innermost group (0-based)
15 fn find_segments_in_group(
16 &self,
17 segment_id: &str,
18 group_path: &[&str],
19 instance_index: usize,
20 ) -> Vec<OwnedSegment>;
21
22 /// Find segments matching a tag + qualifier within a group instance.
23 ///
24 /// * `segment_id` - Segment tag to find
25 /// * `element_index` - Which element contains the qualifier
26 /// * `qualifier` - Expected qualifier value
27 /// * `group_path` - Path of group IDs from root
28 /// * `instance_index` - Which repetition of the innermost group (0-based)
29 fn find_segments_with_qualifier_in_group(
30 &self,
31 segment_id: &str,
32 element_index: usize,
33 qualifier: &str,
34 group_path: &[&str],
35 instance_index: usize,
36 ) -> Vec<OwnedSegment>;
37
38 /// Count repetitions of a group at the given path.
39 fn group_instance_count(&self, group_path: &[&str]) -> usize;
40
41 /// Check if a group instance has any segments at all.
42 ///
43 /// Returns `true` if the group instance at `instance_index` contains at least
44 /// one segment. Used to distinguish genuinely populated group instances from
45 /// navigator implementations that can't resolve per-instance segments.
46 fn has_any_segment_in_group(&self, _group_path: &[&str], _instance_index: usize) -> bool {
47 false // Default: unknown, treat as unpopulated
48 }
49
50 /// Count repetitions of a child group within a specific parent group instance.
51 ///
52 /// * `parent_path` - Path to the parent group (e.g., `&["SG4", "SG8"]`)
53 /// * `parent_instance` - Which repetition of the parent group (0-based)
54 /// * `child_group_id` - ID of the child group to count (e.g., `"SG10"`)
55 fn child_group_instance_count(
56 &self,
57 parent_path: &[&str],
58 parent_instance: usize,
59 child_group_id: &str,
60 ) -> usize {
61 let _ = (parent_path, parent_instance, child_group_id);
62 0
63 }
64
65 /// Find all segments with the given tag within a child group instance.
66 ///
67 /// * `segment_id` - Segment tag to find (e.g., "CCI")
68 /// * `parent_path` - Path to the parent group (e.g., `&["SG4", "SG8"]`)
69 /// * `parent_instance` - Which repetition of the parent group (0-based)
70 /// * `child_group_id` - ID of the child group (e.g., `"SG10"`)
71 /// * `child_instance` - Which repetition of the child group (0-based)
72 fn find_segments_in_child_group(
73 &self,
74 segment_id: &str,
75 parent_path: &[&str],
76 parent_instance: usize,
77 child_group_id: &str,
78 child_instance: usize,
79 ) -> Vec<OwnedSegment> {
80 let _ = (
81 segment_id,
82 parent_path,
83 parent_instance,
84 child_group_id,
85 child_instance,
86 );
87 vec![]
88 }
89
90 /// Extract a single value from the first matching segment in a group instance.
91 ///
92 /// More efficient than `find_segments_in_group` when only one value is needed.
93 ///
94 /// * `segment_id` - Segment tag to find
95 /// * `element_index` - Which element to extract from
96 /// * `component_index` - Which component within the element
97 /// * `group_path` - Path of group IDs from root
98 /// * `instance_index` - Which repetition of the innermost group (0-based)
99 fn extract_value_in_group(
100 &self,
101 segment_id: &str,
102 element_index: usize,
103 component_index: usize,
104 group_path: &[&str],
105 instance_index: usize,
106 ) -> Option<String> {
107 let _ = (
108 segment_id,
109 element_index,
110 component_index,
111 group_path,
112 instance_index,
113 );
114 None
115 }
116}