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>,
    pub differences: Vec<Differences>,
}

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.

§differences: Vec<Differences>

The statements of the difference headers read: a CGMES dm:DifferenceModel’s forward and reverse differences and preconditions, an NC dcatcim:DifferenceSet’s forward and reverse differences, each read into a dataset of its own. The decoder applies none of them; CimDataset::apply does.

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.

Source§

impl CimDataset

Source

pub fn apply(&mut self, d: &Differences) -> Applied

Apply a difference: its preconditions checked, its reverse statements removed, its forward statements added, as IEC 61970-552 describes. An object left with neither type nor values is removed; one given a type it lacked is created. A statement that does not hold is reported (Applied::unmatched) and passed over, not fatal. Several differences apply in turn, in the order the caller gives (along their headers’ Model.Supersedes, say).

Trait Implementations§

Source§

impl Clone for CimDataset

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for CimDataset

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for CimDataset

§

impl Freeze for CimDataset

§

impl Move for CimDataset

§

impl RefUnwindSafe for CimDataset

§

impl Send for CimDataset
where RawTable<(String, Element)>: Send, RawTable<(String, Vec<String>)>: Send, RawTable<((&'static str, &'static str), FieldForm)>: Send, RawTable<(String, &'static str)>: Send, RawTable<(&'static str, &'static str)>: Send, RawVecInner: Send,

§

impl Sync for CimDataset
where RawTable<(String, Element)>: Sync, RawTable<(String, Vec<String>)>: Sync, RawTable<((&'static str, &'static str), FieldForm)>: Sync, RawTable<(String, &'static str)>: Sync, RawTable<(&'static str, &'static str)>: Sync, RawVecInner: Sync,

§

impl Unpin for CimDataset
where *const u8 is !null: Unpin, &'static ClassDef: Unpin, &'static str: Unpin, Box<Vec<(&'static str, Box<str>)>>: Unpin, Box<Vec<&'static ClassDef>>: Unpin,

§

impl UnsafeUnpin for CimDataset

§

impl UnwindSafe for CimDataset

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> Same for T

Source§

type Output = T

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

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.