pub struct TypeRegistry { /* private fields */ }Expand description
Namespace-aware class lookup, and every attribute each class declares.
RDF/XML identifies a class by (namespace, local name), and the two profile
families overlap on 164 local names — both even spell the prefix cim, so
only the xmlns binding distinguishes them. Lookup is therefore keyed on the
resolved namespace, with a bare-name fallback (CGMES only) that preserves
the historical behaviour for files whose prefixes are unbound or unexpected.
Implementations§
Source§impl TypeRegistry
impl TypeRegistry
pub fn new() -> Self
Sourcepub fn add_family(
&mut self,
id: &'static str,
schema: &'static Schema,
bare_fallback: bool,
)
pub fn add_family( &mut self, id: &'static str, schema: &'static Schema, bare_fallback: bool, )
Register a family’s schema under id. bare_fallback adds its classes
to the bare-name fallback: an unbound prefix means the families cannot
be told apart, so only the default family (CGMES) takes it.
Sourcepub fn ns_table(
&self,
ns: &str,
) -> Option<&FastMap<&'static str, &'static ClassDef>>
pub fn ns_table( &self, ns: &str, ) -> Option<&FastMap<&'static str, &'static ClassDef>>
Lookup table for one namespace, resolved once per XML prefix per file.
pub fn bare(&self) -> &FastMap<&'static str, &'static ClassDef>
pub fn by_type_name(&self, name: &str) -> Option<&'static ClassDef>
Sourcepub fn attr(&self, class: &ClassDef, id: &str) -> Option<&'static AttrDef>
pub fn attr(&self, class: &ClassDef, id: &str) -> Option<&'static AttrDef>
The attribute id if class declares it, itself or by inheritance.
Sourcepub fn declared(
&self,
class: &ClassDef,
) -> Option<&FastMap<&'static str, &'static AttrDef>>
pub fn declared( &self, class: &ClassDef, ) -> Option<&FastMap<&'static str, &'static AttrDef>>
The attributes class declares, inherited ones included, by id — for a
caller that resolves many keys of one element.
Sourcepub fn field_key(&self, class: &ClassDef, id: &str) -> &'static str
pub fn field_key(&self, class: &ClassDef, id: &str) -> &'static str
The &'static key a field id of class is stored under.
Sourcepub fn chain(&self, class: &ClassDef) -> &[&'static ClassDef]
pub fn chain(&self, class: &ClassDef) -> &[&'static ClassDef]
class and its ancestors, root first.
Sourcepub fn concrete_descendants(&self, qualified: &str) -> Vec<&'static str>
pub fn concrete_descendants(&self, qualified: &str) -> Vec<&'static str>
The by_type keys of the concrete classes at or below qualified,
sorted: what instances of a class can be typed as.
Sourcepub fn attrs(
&self,
class: &ClassDef,
) -> impl Iterator<Item = &'static AttrDef> + '_
pub fn attrs( &self, class: &ClassDef, ) -> impl Iterator<Item = &'static AttrDef> + '_
Every attribute class declares, inherited ones included.
Sourcepub fn schema(&self, family: &str) -> Option<&'static Schema>
pub fn schema(&self, family: &str) -> Option<&'static Schema>
The schema registered as family ("cgmes", "nc").
Sourcepub fn enum_value(
&self,
class: &ClassDef,
id: &str,
) -> Option<(&'static EnumDef, &'static EnumValueDef)>
pub fn enum_value( &self, class: &ClassDef, id: &str, ) -> Option<(&'static EnumDef, &'static EnumValueDef)>
The enumeration value id (WindingConnection.D) in the family of
class, which an element of class uses it on.
Sourcepub fn family_of(&self, type_name: &str) -> Option<&'static str>
pub fn family_of(&self, type_name: &str) -> Option<&'static str>
The family a by_type key belongs to, by its prefix.