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
impl PathResolver
Sourcepub fn from_schema(schema: &Value) -> Self
pub fn from_schema(schema: &Value) -> Self
Build from a PID schema JSON (serde_json::Value).
Walks all groups recursively, collecting segment element indices.
Sourcepub fn from_schema_dir(dir: &Path) -> Self
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.
Sourcepub fn merge_schema(&mut self, schema: &Value)
pub fn merge_schema(&mut self, schema: &Value)
Merge another PID schema into this resolver.
Sourcepub fn resolve_path(&self, path: &str) -> String
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)
Sourcepub fn resolve_discriminator(&self, disc: &str) -> String
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
impl Clone for PathResolver
Source§fn clone(&self) -> PathResolver
fn clone(&self) -> PathResolver
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more