pub struct CodeLookup { /* private fields */ }Expand description
Complete code lookup table built from a PID schema JSON.
Entries are scoped by the segment variant’s qualifier. Tags with a qualifier
convention (RFF/STS/CCI/DTM) are stored only under their qualifier. Other
tags (NAD, CAV, FTX, …) are stored under None (the union of all same-tag
segments, for unqualified lookups) and additionally under their own leading
code when the schema fixes it to one value (e.g. CAV+Z91), so a qualified
lookup (cav[Z91]) sees only the codes of that segment variant.
Implementations§
Source§impl CodeLookup
impl CodeLookup
Sourcepub fn from_schema_file(path: &Path) -> Result<Self, Error>
pub fn from_schema_file(path: &Path) -> Result<Self, Error>
Build a CodeLookup from a PID schema JSON file.
Sourcepub fn from_schema_value(schema: &Value) -> Self
pub fn from_schema_value(schema: &Value) -> Self
Build a CodeLookup from an already-parsed PID schema JSON value.
Sourcepub fn enrichment_codes(
&self,
source_path: &str,
segment_tag: &str,
path_qualifier: Option<&str>,
disc_qualifier: Option<&str>,
element_index: usize,
component_index: usize,
) -> Option<&CodeMeanings>
pub fn enrichment_codes( &self, source_path: &str, segment_tag: &str, path_qualifier: Option<&str>, disc_qualifier: Option<&str>, element_index: usize, component_index: usize, ) -> Option<&CodeMeanings>
Codes a mapped field is enriched with ({code, meaning}), None if the
engine writes it as a plain value.
path_qualifier is the field path’s tag[Q] selector, disc_qualifier
the definition’s discriminator value when the discriminator is on the same
segment tag. Which positions get enriched follows the discriminator (as it
always has); a path qualifier only narrows the codes to the segment variant
the field actually reads, and suppresses enrichment where that variant has
no code at the position (e.g. rff[ACW].c506.d1154 next to RFF+Z13).
Sourcepub fn field_codes(
&self,
source_path: &str,
segment_tag: &str,
path_qualifier: Option<&str>,
disc_qualifier: Option<&str>,
element_index: usize,
component_index: usize,
) -> Option<CodeMeanings>
pub fn field_codes( &self, source_path: &str, segment_tag: &str, path_qualifier: Option<&str>, disc_qualifier: Option<&str>, element_index: usize, component_index: usize, ) -> Option<CodeMeanings>
Codes a mapped field can hold, whether enriched or not: those of the
segment variant selected by the path qualifier or the same-tag
discriminator; without either, the union over every variant (the field
reads whichever segment instance is present). None if not a code field.
Sourcepub fn is_known_variant(
&self,
source_path: &str,
segment_tag: &str,
qualifier: &str,
) -> bool
pub fn is_known_variant( &self, source_path: &str, segment_tag: &str, qualifier: &str, ) -> bool
Whether qualifier names a segment variant of segment_tag at source_path
(i.e. the schema has a segment_tag segment whose leading code is fixed to it).
Sourcepub fn is_code_field(
&self,
source_path: &str,
segment_tag: &str,
element_index: usize,
component_index: usize,
) -> bool
👎Deprecated: use is_code_field_q with the discriminator qualifier; this shim scans across all qualifiers
pub fn is_code_field( &self, source_path: &str, segment_tag: &str, element_index: usize, component_index: usize, ) -> bool
use is_code_field_q with the discriminator qualifier; this shim scans across all qualifiers
Check if the field at the given position is a code-type field.
Legacy shim — scans across all qualifier slots and returns true if ANY
matching entry exists for the (path, tag, elem, comp) tuple. This drifts
from the original “call _q with None” prescription but is more useful
for tests that don’t have a qualifier handy. Production code paths use
[is_code_field_q] with the discriminator qualifier and a None
fallback for tags without a stored qualifier convention.
Sourcepub fn is_code_field_q(
&self,
source_path: &str,
segment_tag: &str,
qualifier: Option<&str>,
element_index: usize,
component_index: usize,
) -> bool
pub fn is_code_field_q( &self, source_path: &str, segment_tag: &str, qualifier: Option<&str>, element_index: usize, component_index: usize, ) -> bool
Qualifier-aware variant: check if the position is a code field for the given qualifier.
When qualifier names a segment variant of the tag (see
is_known_variant), only that variant’s entry
counts: RFF+TN d1154 (data) is not a code field even though RFF+Z13 d1154
is. A qualifier that names no variant (e.g. a discriminator value of
another segment) and None use the unqualified entry.
Sourcepub fn codes_q(
&self,
source_path: &str,
segment_tag: &str,
qualifier: Option<&str>,
element_index: usize,
component_index: usize,
) -> Option<&CodeMeanings>
pub fn codes_q( &self, source_path: &str, segment_tag: &str, qualifier: Option<&str>, element_index: usize, component_index: usize, ) -> Option<&CodeMeanings>
All codes (with their enrichment data) of the code field at the given
position, resolved exactly like is_code_field_q. None if the
position is not a code field (for that segment variant).
Sourcepub fn codes_all_qualifiers(
&self,
source_path: &str,
segment_tag: &str,
element_index: usize,
component_index: usize,
) -> CodeMeanings
pub fn codes_all_qualifiers( &self, source_path: &str, segment_tag: &str, element_index: usize, component_index: usize, ) -> CodeMeanings
Codes of the given position under every qualifier slot, merged. A definition without a discriminator reads whichever segment instance is present, so its values range over all of them.
Sourcepub fn enrichment_for(
&self,
source_path: &str,
segment_tag: &str,
element_index: usize,
component_index: usize,
value: &str,
) -> Option<&CodeEnrichment>
👎Deprecated: use enrichment_for_q with the discriminator qualifier; this shim scans across all qualifiers
pub fn enrichment_for( &self, source_path: &str, segment_tag: &str, element_index: usize, component_index: usize, value: &str, ) -> Option<&CodeEnrichment>
use enrichment_for_q with the discriminator qualifier; this shim scans across all qualifiers
Get the full enrichment data for a code value at the given position.
Legacy shim — scans across all qualifier slots. See [enrichment_for_q]
for the qualifier-aware version used by the engine. Kept for tests.
Sourcepub fn enrichment_for_q(
&self,
source_path: &str,
segment_tag: &str,
qualifier: Option<&str>,
element_index: usize,
component_index: usize,
value: &str,
) -> Option<&CodeEnrichment>
pub fn enrichment_for_q( &self, source_path: &str, segment_tag: &str, qualifier: Option<&str>, element_index: usize, component_index: usize, value: &str, ) -> Option<&CodeEnrichment>
Qualifier-aware enrichment lookup, resolved like
is_code_field_q.
Sourcepub fn meaning_for(
&self,
source_path: &str,
segment_tag: &str,
element_index: usize,
component_index: usize,
value: &str,
) -> Option<&str>
👎Deprecated: use enrichment_for_q with the discriminator qualifier; this shim scans across all qualifiers
pub fn meaning_for( &self, source_path: &str, segment_tag: &str, element_index: usize, component_index: usize, value: &str, ) -> Option<&str>
use enrichment_for_q with the discriminator qualifier; this shim scans across all qualifiers
Get the human-readable meaning for a code value at the given position.
Returns None if the position is not a code field or the value is unknown.
Legacy shim — scans across all qualifier slots via [enrichment_for].
Kept for tests; production code paths use the qualifier-aware
enrichment_for_q.
Sourcepub fn is_pid_self_reference(
&self,
source_path: &str,
segment_tag: &str,
qualifier: Option<&str>,
element_index: usize,
component_index: usize,
pid: &str,
) -> bool
pub fn is_pid_self_reference( &self, source_path: &str, segment_tag: &str, qualifier: Option<&str>, element_index: usize, component_index: usize, pid: &str, ) -> bool
Whether this code-field’s only allowed value equals the given PID.
Used to suppress decoration for self-referential PID-identifier fields
(Class C in the 2026-04-28 audit). The qualifier scopes the lookup —
e.g., RFF+Z13’s d1154 in PID 55002 has value=55002 as the lone code,
so calling with qualifier=Some("Z13"), pid="55002" returns true.