pub struct CodeLookup { /* private fields */ }Expand description
Complete code lookup table built from a PID schema JSON.
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 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 a companion 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. The schema’s stored qualifier slot is Some only for
tags with a qualifier convention (RFF/STS/CCI/DTM); other tags (NAD,
SEQ, LOC, BGM, COM, MOA, …) store entries under None. When the strict
match misses for Some(q), this falls back to the None entry so that
TOMLs discriminated on those tags (e.g. discriminator = "NAD.d3035=Z09")
still resolve enrichment correctly.
Class A discrimination still works: for RFF, both Z13 (type=code) and
TN (type=data) carry stored qualifiers, so the strict Some("Z13")
match finds Z13 and the strict Some("TN") match finds nothing — the
None fallback also misses (RFF entries are all qualifier-scoped),
so TN free-text returns false.
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.
Strict match on the stored qualifier slot first; on miss with
qualifier.is_some(), falls back to the None entry. This mirrors
[is_code_field_q]’s lookup shape — segments like NAD/SEQ/LOC store
their entries under None even when the engine queries with the
discriminator’s qualifier value (e.g. Some("Z09") from a
NAD.d3035=Z09 discriminator).
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.
Trait Implementations§
Source§impl Clone for CodeLookup
impl Clone for CodeLookup
Source§fn clone(&self) -> CodeLookup
fn clone(&self) -> CodeLookup
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more