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.

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

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

Source

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.

Source

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

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

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.

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.

Source

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

Source

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.

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, resolved like is_code_field_q.

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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() -> Self

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.