Skip to main content

CimDataset

Struct CimDataset 

Source
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

Source

pub fn new() -> Self

Source

pub fn decode_str(content: &str) -> Result<Self, Box<dyn Error>>

Decode an RDF/XML string into a CimDataset, using the provided type registry.

Source

pub fn decode_file(path: &Path) -> Result<Self, Box<dyn Error>>

Decode an RDF/XML file into a CimDataset, using the provided type registry.

Source

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.

Source

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.

Source

pub fn decode_files_parallel(paths: &[&Path]) -> Result<Self, Box<dyn Error>>

Decode files in parallel using one thread per file, then merge sequentially.

Source

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.

Source

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.

Source

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

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for CimDataset

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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> Same for T

Source§

type Output = T

Should always be Self
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.