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
impl DomIndex
Sourcepub fn build(records: Vec<DomRecord>) -> Self
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).
Sourcepub fn records(&self) -> &[DomRecord]
pub fn records(&self) -> &[DomRecord]
All records, unspecified order. Query callers sort by
DomRecord::doc_order.
Sourcepub fn get_by_id(&self, id: &str) -> Option<Entity>
pub fn get_by_id(&self, id: &str) -> Option<Entity>
Fast id lookup (get_by_id), first match in document order.
Sourcepub fn document(&self) -> Option<Entity>
pub fn document(&self) -> Option<Entity>
The document root (document()), the first root in order.
Sourcepub fn parent(&self, entity: Entity) -> Option<Entity>
pub fn parent(&self, entity: Entity) -> Option<Entity>
Parent of entity, if any (node.parent()).
Sourcepub fn children(&self, entity: Entity) -> Vec<Entity>
pub fn children(&self, entity: Entity) -> Vec<Entity>
Ordered children of entity (node.children()).
Sourcepub fn first_child(&self, entity: Entity) -> Option<Entity>
pub fn first_child(&self, entity: Entity) -> Option<Entity>
First child (node.first_child()).
Sourcepub fn last_child(&self, entity: Entity) -> Option<Entity>
pub fn last_child(&self, entity: Entity) -> Option<Entity>
Last child (node.last_child()).
Sourcepub fn next_sibling(&self, entity: Entity) -> Option<Entity>
pub fn next_sibling(&self, entity: Entity) -> Option<Entity>
Next sibling in document order (node.next()).
Sourcepub fn prev_sibling(&self, entity: Entity) -> Option<Entity>
pub fn prev_sibling(&self, entity: Entity) -> Option<Entity>
Previous sibling in document order (node.prev()).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DomIndex
impl RefUnwindSafe for DomIndex
impl Send for DomIndex
impl Sync for DomIndex
impl Unpin for DomIndex
impl UnsafeUnpin for DomIndex
impl UnwindSafe for DomIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().