Skip to main content

DomIndex

Struct DomIndex 

Source
pub struct DomIndex { /* private fields */ }
Expand description

Immutable per-tick snapshot of the selector-reachable element tree. Traversal and get_by_id read this directly; selector queries run in lumen-script over the same records.

Implementations§

Source§

impl DomIndex

Source

pub fn build(records: Vec<DomRecord>) -> Self

Build a snapshot from unordered records. Each record must carry its parent and ordered children; this computes sibling positions, depth-first document order, the entity and id lookup maps, and the root list. The last id wins on a duplicate (matching cascade “first match by document order” is applied by get_by_id reading the first-in-doc-order entry).

Source

pub fn records(&self) -> &[DomRecord]

All records, unspecified order. Query callers sort by DomRecord::doc_order.

Source

pub fn record(&self, entity: Entity) -> Option<&DomRecord>

Look up a record by entity.

Source

pub fn get_by_id(&self, id: &str) -> Option<Entity>

Fast id lookup (get_by_id), first match in document order.

Source

pub fn roots(&self) -> &[Entity]

Root elements, ordered.

Source

pub fn document(&self) -> Option<Entity>

The document root (document()), the first root in order.

Source

pub fn parent(&self, entity: Entity) -> Option<Entity>

Parent of entity, if any (node.parent()).

Source

pub fn children(&self, entity: Entity) -> Vec<Entity>

Ordered children of entity (node.children()).

Source

pub fn first_child(&self, entity: Entity) -> Option<Entity>

First child (node.first_child()).

Source

pub fn last_child(&self, entity: Entity) -> Option<Entity>

Last child (node.last_child()).

Source

pub fn next_sibling(&self, entity: Entity) -> Option<Entity>

Next sibling in document order (node.next()).

Source

pub fn prev_sibling(&self, entity: Entity) -> Option<Entity>

Previous sibling in document order (node.prev()).

Source

pub fn ancestors(&self, entity: Entity) -> Vec<Entity>

The ancestor chain of entity, closest-parent-first (not including entity). Used by lumen-script to build the root-first AncestorInfo slice the selector matcher consumes.

Trait Implementations§

Source§

impl Debug for DomIndex

Source§

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

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

impl Default for DomIndex

Source§

fn default() -> DomIndex

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.

§

impl<T> FromWorld for T
where T: Default,

§

fn from_world(_world: &mut World) -> T

Creates Self using default().

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.

§

impl<T> IntoResult<T> for T

§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> ConditionalSend for T
where T: Send,