⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

Document

Struct Document 

Source
pub struct Document {
    pub arena: NodeArena,
    pub root: NodeId,
}
Expand description

The DOM Document

Fields§

§arena: NodeArena§root: NodeId

Implementations§

Source§

impl Document

Source

pub fn new() -> Self

Create a new empty document

Source

pub fn create_element(&mut self, tag_name: &str) -> NodeId

Create an element node

Source

pub fn create_element_with_attrs( &mut self, tag_name: &str, attrs: BTreeMap<String, String>, ) -> NodeId

Create an element node with attributes

Source

pub fn create_text(&mut self, text: &str) -> NodeId

Create a text node

Source

pub fn create_comment(&mut self, text: &str) -> NodeId

Create a comment node

Source

pub fn create_doctype(&mut self, name: &str) -> NodeId

Create a document type node

Source

pub fn append_child(&mut self, parent_id: NodeId, child_id: NodeId)

Append a child node to a parent

Source

pub fn remove_child(&mut self, parent_id: NodeId, child_id: NodeId)

Remove a child from its parent

Source

pub fn insert_before( &mut self, parent_id: NodeId, new_child_id: NodeId, ref_child_id: NodeId, )

Insert a child before a reference node

Source

pub fn get_element_by_id(&self, id: &str) -> Option<NodeId>

Find an element by its “id” attribute

Source

pub fn get_elements_by_tag_name(&self, tag: &str) -> Vec<NodeId>

Find all elements with a given tag name

Source

pub fn walk<F: FnMut(NodeId)>(&self, start: NodeId, callback: &mut F)

Walk the tree depth-first, calling the callback on each node

Source

pub fn descendants(&self, start: NodeId) -> Vec<NodeId>

Get all descendant NodeIds (depth-first)

Source

pub fn ancestors(&self, start: NodeId) -> Vec<NodeId>

Get all ancestor NodeIds (from parent up to root)

Source

pub fn inner_text(&self, node_id: NodeId) -> String

Get the inner text of a node (concatenation of all text descendants)

Source

pub fn outer_html(&self, node_id: NodeId) -> String

Generate outer HTML for debugging

Source

pub fn tag_name(&self, node_id: NodeId) -> Option<&str>

Get the tag name of an element node

Source

pub fn get_attribute(&self, node_id: NodeId, attr: &str) -> Option<String>

Get an attribute value from an element node

Source

pub fn node_count(&self) -> usize

Count total nodes in the arena

Trait Implementations§

Source§

impl Debug for Document

Source§

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

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

impl Default for Document

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Document

§

impl RefUnwindSafe for Document

§

impl Send for Document

§

impl Sync for Document

§

impl Unpin for Document

§

impl UnwindSafe for Document

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.