pub struct CimDataset {
pub entries: FastMap<String, Element>,
pub by_type: FastMap<String, Vec<String>>,
pub field_forms: FastMap<(&'static str, &'static str), FieldForm>,
pub type_ns: FastMap<String, &'static str>,
pub prefixes: FastMap<&'static str, &'static str>,
pub foreign: FastMap<String, Element>,
}Fields§
§entries: FastMap<String, Element>§by_type: FastMap<String, Vec<String>>Maps type_name() → list of MRIDs of that type. Populated on insert, maintained on merge.
field_forms: FastMap<(&'static str, &'static str), FieldForm>How the files wrote each field, by the class of its object
(type_name()) and its key, where the class tables cannot tell and the
decoded value no longer shows: what the encoder needs to write the
field back as it was read. By class, because one document may use one
local name in two vocabularies (dcterms:type on a dataset,
prov:type on an activity).
type_ns: FastMap<String, &'static str>The namespace an object’s element was written in, by mRID, where it is
not its class’s: a class the decoder found by local name only
(cim:BoundaryPoint for CIM100-European’s, an NC file’s
cim:PhaseTapChangerLinear for CGMES’s). First file wins.
prefixes: FastMap<&'static str, &'static str>The prefix the files bound each namespace to (qudt →
http://qudt.org/schema/qudt/), for the encoder to reuse. First file
wins.
foreign: FastMap<String, Element>Objects of classes no class table knows — reference data’s SKOS
concepts, PROV agents, DCAT catalogues — keyed by their identifier as
written: the full IRI of rdf:about, _: and the rdf:nodeID of a
blank node. Kept apart from entries so that validation, SPARQL and
every lookup of a CIM object see only CIM objects; the encoder writes
them back (crate::convert::dataset_to_xml). Their classes come from
crate::base::foreign_class.
Implementations§
Source§impl CimDataset
impl CimDataset
pub fn new() -> Self
Sourcepub fn decode_str(content: &str) -> Result<Self, Box<dyn Error>>
pub fn decode_str(content: &str) -> Result<Self, Box<dyn Error>>
Decode an RDF/XML string into a CimDataset, using the provided type registry.
Sourcepub fn decode_file(path: &Path) -> Result<Self, Box<dyn Error>>
pub fn decode_file(path: &Path) -> Result<Self, Box<dyn Error>>
Decode an RDF/XML file into a CimDataset, using the provided type registry.
Sourcepub fn decode_files(paths: &[&Path]) -> Result<Self, Box<dyn Error>>
pub fn decode_files(paths: &[&Path]) -> Result<Self, Box<dyn Error>>
Decode multiple RDF/XML files into a single CimDataset, merging entries with the same MRID.
Sourcepub fn decode_files_parallel_separate(
paths: &[&Path],
) -> Result<Vec<Self>, Box<dyn Error>>
pub fn decode_files_parallel_separate( paths: &[&Path], ) -> Result<Vec<Self>, Box<dyn Error>>
Decode files in parallel using one thread per file, without merging. Preserves input order. Falls back to sequential decoding for 0–1 paths to avoid thread-spawn overhead.
Sourcepub fn decode_files_parallel(paths: &[&Path]) -> Result<Self, Box<dyn Error>>
pub fn decode_files_parallel(paths: &[&Path]) -> Result<Self, Box<dyn Error>>
Decode files in parallel using one thread per file, then merge sequentially.
Sourcepub fn merge(&mut self, other: CimDataset)
pub fn merge(&mut self, other: CimDataset)
Merge another dataset into self, combining objects with the same MRID: a later scalar wins, reference lists are joined. An object keeps the class it was first decoded as.
Where the files type an object differently — an SSH file writing
cim:Equipment for what the EQ file wrote as cim:ACLineSegment — the
object keeps every type, as the RDF union does (Element::types),
and its class (and by_type bucket) is the most specific, whichever
file came first. Of unrelated classes the first stays the class.
Sourcepub fn element_from_json(
&self,
class: &'static ClassDef,
value: &Value,
) -> Result<Element, String>
pub fn element_from_json( &self, class: &'static ClassDef, value: &Value, ) -> Result<Element, String>
An element of class from its JSON form (Element::from_json), with
the dataset as evidence for what JSON cannot say: whether a field’s
string is a reference or text. Where this dataset holds the field on an
object of the same class, it is held the same way — a DCAT header’s
undeclared conformsTo as a reference, dcat:version, which the NC
table declares an association, as the text the data writes. Otherwise
the class table decides, and an undeclared field is text.
Sourcepub fn set(&mut self, mrid: String, element: Element)
pub fn set(&mut self, mrid: String, element: Element)
Insert or replace the element at mrid, keeping by_type consistent
(including the case where mrid already exists under a different type).
Sourcepub fn remove(&mut self, mrid: &str) -> Option<Element>
pub fn remove(&mut self, mrid: &str) -> Option<Element>
Remove the element at mrid, pruning it from by_type. Returns the
removed element, or None if mrid was not present.
Sourcepub fn type_conflicts(&self) -> Vec<(&str, Vec<&'static str>)>
pub fn type_conflicts(&self) -> Vec<(&str, Vec<&'static str>)>
The objects the files typed with classes of which neither is the
other’s ancestor, sorted, each with its types: what a merge of datasets
that disagree about an object leaves (CimDataset::merge keeps every
type). An SSH file’s cim:Equipment for an EQ cim:ACLineSegment is a
superclass, not a conflict.