Skip to main content

Index

Struct Index 

Source
pub struct Index {
    pub namespaces: Vec<(String, String)>,
    pub elements: Vec<Element>,
    /* private fields */
}

Fields§

§namespaces: Vec<(String, String)>

xmlns bindings of the root element: (prefix, IRI); "" for the default namespace.

§elements: Vec<Element>

Implementations§

Source§

impl Index

Source

pub fn build(text: &str) -> Self

Source§

impl Index

Source

pub fn edited( self, old: &str, old_lines: &LineIndex, new: &str, new_lines: &LineIndex, edits: &[TextEdit], ) -> Result<(Index, Vec<String>), Index>

The index of new: this index’s text, old, with edits applied (each placed in old as it was), the lines of each counted. Only what the edits changed is read again, widened to whole elements and lines; the elements after it keep theirs, moved by the lines it added or took. Some 0.02 s for an edit of RealGrid’s EQ file, where reading it whole takes 0.5 s. With the mRIDs of the objects written where the edits are, before and after them: those they touched.

Err gives this index back for an edit around the objects (the XML declaration, the root element) or one that leaves an element open: read new whole.

Source

pub fn of(&self, mrid: &str) -> impl Iterator<Item = &Element>

The elements writing the object mrid, in document order.

Source

pub fn places_of(&self, mrid: &str) -> &[u32]

The places in elements of those writing the object mrid, in document order.

Source

pub fn namespace(&self, prefix: &str) -> Option<&str>

The namespace IRI prefix is bound to at the root.

Source

pub fn prefix_of(&self, ns: &str) -> Option<&str>

The prefix bound to ns at the root.

Source

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

The class of an element written qname here: by its prefix’s namespace, else by its local name alone.

Source

pub fn element_at(&self, pos: Position) -> Option<&Element>

The element whose start-to-end span contains pos.

Trait Implementations§

Source§

impl Debug for Index

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Index

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.