Skip to main content

Node

Struct Node 

Source
#[repr(C, align(64))]
pub struct Node {
Show 18 fields pub tag: Tag, pub flags: NodeFlags, pub depth: u16, pub parent: NodeId, pub first_child: NodeId, pub next_sibling: NodeId, pub last_child: NodeId, pub prev_sibling: NodeId, pub text_offset: u32, pub text_len: u32, pub attr_offset: u32, pub attr_raw_offset: u32, pub class_hash: u64, pub id_hash: u32, pub attr_raw_len: u16, pub element_index: u16, pub attr_count: u8, pub _padding: [u8; 7],
}
Expand description

A single DOM node in the arena, exactly 64 bytes (one cache line).

The first 32 bytes contain frequently accessed fields (tree links, tag, depth). The second 32 bytes contain less-frequently accessed data (attribute metadata).

§Layout

OffsetBytesField
01tag
11flags
22depth
44parent
84first_child
124next_sibling
164last_child
204prev_sibling
244text_offset
284text_len
324attr_offset
364attr_raw_offset
408class_hash
484id_hash
522attr_raw_len
542element_index
561attr_count
577_padding

Fields§

§tag: Tag

Interned tag type.

§flags: NodeFlags

Bitflags for node properties.

§depth: u16

Nesting depth from root (root = 0).

§parent: NodeId

Parent node, or NodeId::NULL for root.

§first_child: NodeId

First child, or NodeId::NULL if no children.

§next_sibling: NodeId

Next sibling, or NodeId::NULL if last.

§last_child: NodeId

Last child, or NodeId::NULL if no children.

§prev_sibling: NodeId

Previous sibling, or NodeId::NULL if first.

§text_offset: u32

Byte offset into the text slab.

§text_len: u32

Length in bytes of the text content in the slab.

§attr_offset: u32

Byte offset into the attribute slab (after lazy parse).

§attr_raw_offset: u32

Byte offset into attr_str_slab for the raw attribute region.

§class_hash: u64

64-bit bloom filter of class attribute tokens.

Each class token is hashed via FNV-1a and a single bit is set at hash % 64. Zero means no class attribute. Used by the selector matcher for fast rejection. 64 bits reduces false positive rate from ~15% (5 classes) to ~8% compared to 32-bit.

§id_hash: u32

FNV-1a hash of the id attribute value.

Zero means no id attribute. Used by the selector matcher for fast rejection before scanning attributes.

§attr_raw_len: u16

Length in bytes of the raw attribute region (max 65535).

§element_index: u16

1-based index among element siblings (0 = not computed or text node).

§attr_count: u8

Number of attributes (0 with raw data present = unparsed lazy).

§_padding: [u8; 7]

Padding to fill the cache line.

Implementations§

Source§

impl Node

Source

pub fn new_element(tag: Tag, depth: u16) -> Self

Create a new element node with all links set to NULL.

Source

pub fn new_text(depth: u16, text_offset: u32, text_len: u32) -> Self

Create a new text node.

Source

pub fn new_comment(depth: u16, text_offset: u32, text_len: u32) -> Self

Create a new comment node.

Source

pub fn new_doctype(depth: u16, text_offset: u32, text_len: u32) -> Self

Create a new doctype node.

Trait Implementations§

Source§

impl Debug for Node

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

§

impl UnwindSafe for Node

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