Skip to main content

CodeLookup

Struct CodeLookup 

Source
pub struct CodeLookup { /* private fields */ }
Expand description

Complete code lookup table built from a PID schema JSON.

Implementations§

Source§

impl CodeLookup

Source

pub fn from_schema_file(path: &Path) -> Result<Self, Error>

Build a CodeLookup from a PID schema JSON file.

Source

pub fn from_schema_value(schema: &Value) -> Self

Build a CodeLookup from an already-parsed PID schema JSON value.

Source

pub 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

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.

Source

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.

Source

pub 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

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.

Source

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).

Source

pub 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

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.

Source

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

Source§

fn clone(&self) -> CodeLookup

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CodeLookup

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CodeLookup

Source§

fn default() -> CodeLookup

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for CodeLookup

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for CodeLookup

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,