Skip to main content

PathResolver

Struct PathResolver 

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

Resolves EDIFACT ID paths to numeric element indices.

Built from a PID schema JSON. Used at TOML load time to normalize named paths (e.g., “loc.c517.d3225”) to numeric paths (“loc.1.0”).

Supports ordinal suffixes for duplicate IDs:

  • Duplicate composites per segment: c556 (first), c556_2 (second), c556_3 (third)
  • Duplicate data elements per composite: d3036 (first), d3036_2 (second), etc.

Implementations§

Source§

impl PathResolver

Source

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

Build from a PID schema JSON (serde_json::Value).

Walks all groups recursively, collecting segment element indices.

Source

pub fn from_schema_dir(dir: &Path) -> Self

Build from all PID schema JSON files in a directory.

Loads every pid_*_schema.json file and merges their element mappings. This ensures comprehensive coverage across all PIDs.

Source

pub fn merge_schema(&mut self, schema: &Value)

Merge another PID schema into this resolver.

Source

pub fn resolve_path(&self, path: &str) -> String

Resolve a single field path. Returns the numeric path if the input is a named path; returns the input unchanged if already numeric.

Examples:

  • "loc.c517.d3225""loc.1.0"
  • "seq.d1229""seq.0"
  • "cav[Z91].c889.d7111""cav[Z91].0.0"
  • "sts.c556_2.d9013""sts.3.0" (ordinal suffix for duplicate composite)
  • "nad.c080.d3036_2""nad.3.1" (ordinal suffix for duplicate data element)
  • "loc.1.0""loc.1.0" (unchanged)
Source

pub fn resolve_discriminator(&self, disc: &str) -> String

Resolve a discriminator string to 3-part numeric format.

The engine’s resolve_repetition requires TAG.N.M=VALUE (3-part).

Input formats:

  • Named simple: "SEQ.d1229=ZF0""SEQ.0.0=ZF0"
  • Named composite: "STS.c556.d9013=E01""STS.2.0=E01"
  • Numeric 3-part: "LOC.0.0=Z16""LOC.0.0=Z16" (unchanged)
  • Numeric 2-part: "SEQ.0=ZF0""SEQ.0.0=ZF0" (upgraded)

Trait Implementations§

Source§

impl Clone for PathResolver

Source§

fn clone(&self) -> PathResolver

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

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.