pub struct VariantCache {
pub message_defs: Vec<MappingDefinition>,
pub transaction_defs: HashMap<String, Vec<MappingDefinition>>,
pub combined_defs: HashMap<String, Vec<MappingDefinition>>,
pub code_lookups: HashMap<String, CodeLookup>,
pub mig_schema: Option<MigSchema>,
pub segment_structure: Option<SegmentStructure>,
pub pid_segment_numbers: HashMap<String, Vec<String>>,
pub pid_requirements: HashMap<String, PidRequirements>,
pub tx_groups: HashMap<String, String>,
}Expand description
Precompiled cache for a single format-version/variant (e.g., FV2504/UTILMD_Strom).
Contains all engines with paths pre-resolved, ready for immediate use.
Loading one VariantCache file replaces thousands of individual .bin reads.
Fields§
§message_defs: Vec<MappingDefinition>Message-level definitions (shared across PIDs).
transaction_defs: HashMap<String, Vec<MappingDefinition>>Per-PID transaction definitions (key: “pid_55001”).
combined_defs: HashMap<String, Vec<MappingDefinition>>Per-PID combined definitions (key: “pid_55001”).
code_lookups: HashMap<String, CodeLookup>Per-PID code lookups (key: “pid_55001”). Cached to avoid reading schema JSONs at load time.
mig_schema: Option<MigSchema>Parsed MIG schema — cached to avoid re-parsing MIG XML at startup.
segment_structure: Option<SegmentStructure>Segment element counts derived from MIG — cached for reverse mapping padding.
pid_segment_numbers: HashMap<String, Vec<String>>Per-PID AHB segment numbers (key: “pid_55001”). Used for MIG filtering at runtime. Eliminates the need to parse AHB XML files at startup.
pid_requirements: HashMap<String, PidRequirements>Per-PID field requirements (key: “pid_55001”). Built from PID schema + TOML definitions.
Used by validate_pid() to check field completeness.
tx_groups: HashMap<String, String>Per-PID transaction group ID (key: “pid_55001”, value: “SG4”).
Derived from the common source_group prefix of transaction definitions.
Empty string for message-only variants (e.g., ORDCHG).
Implementations§
Source§impl VariantCache
impl VariantCache
Sourcepub fn save(&self, path: &Path) -> Result<(), MappingError>
pub fn save(&self, path: &Path) -> Result<(), MappingError>
Save this variant cache to a single JSON file.
Sourcepub fn load(path: &Path) -> Result<VariantCache, MappingError>
pub fn load(path: &Path) -> Result<VariantCache, MappingError>
Load a variant cache from a single JSON file.
Sourcepub fn tx_group(&self, pid: &str) -> Option<&str>
pub fn tx_group(&self, pid: &str) -> Option<&str>
Get the transaction group for a PID (e.g., “SG4” for UTILMD PIDs).
Returns None if the PID is not in this variant.
Returns Some("") for message-only variants (no transaction group).
Sourcepub fn msg_engine(&self) -> MappingEngine
pub fn msg_engine(&self) -> MappingEngine
Build a MappingEngine from the message-level definitions.
Sourcepub fn tx_engine(&self, pid: &str) -> Option<MappingEngine>
pub fn tx_engine(&self, pid: &str) -> Option<MappingEngine>
Build a MappingEngine from the transaction-level definitions for a PID.
Returns None if the PID is not in this variant.
Sourcepub fn filtered_mig(&self, pid: &str) -> Option<MigSchema>
pub fn filtered_mig(&self, pid: &str) -> Option<MigSchema>
Get a PID-filtered MIG schema.
Returns None if no MIG schema or no segment numbers for this PID.