Skip to main content

TypeRegistry

Struct TypeRegistry 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

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.

Source

pub fn bare(&self) -> &FastMap<&'static str, &'static ClassDef>

Source

pub fn by_type_name(&self, name: &str) -> Option<&'static ClassDef>

Source

pub fn attr(&self, class: &ClassDef, id: &str) -> Option<&'static AttrDef>

The attribute id if class declares it, itself or by inheritance.

Source

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.

Source

pub fn field_key(&self, class: &ClassDef, id: &str) -> &'static str

The &'static key a field id of class is stored under.

Source

pub fn chain(&self, class: &ClassDef) -> &[&'static ClassDef]

class and its ancestors, root first.

Source

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.

Source

pub fn attrs( &self, class: &ClassDef, ) -> impl Iterator<Item = &'static AttrDef> + '_

Every attribute class declares, inherited ones included.

Source

pub fn schema(&self, family: &str) -> Option<&'static Schema>

The schema registered as family ("cgmes", "nc").

Source

pub fn family_of(&self, type_name: &str) -> Option<&'static str>

The family a by_type key belongs to, by its prefix.

Source

pub fn family_attr(&self, family: &str, id: &str) -> Option<&'static AttrDef>

The attribute id as family declares it on any class — what a field key names when the element’s own class does not declare it.

Source

pub fn attr_of(&self, class: &ClassDef, key: &str) -> Option<&'static AttrDef>

The attribute a field key of an element of class stands for: the class’s own declaration, else the family’s.

Trait Implementations§

Source§

impl Default for TypeRegistry

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.