pub enum Node {
Element(Element),
Text(String),
Fragment(Vec<Node>),
Comment(String),
Empty,
}
Expand description
Represents a node in the RSX tree.
Nodes are the fundamental building blocks of RSX. They can be:
- Elements (like
<div>
or<p>
) - Text content
- Fragments (groups of nodes)
- Comments
§Example
use simple_rsx::*;
let text_node = Node::Text("Hello".to_string());
let element_node = Element::parse_tag("div");
let fragment = Node::Fragment(vec![text_node, element_node]);
Variants§
Element(Element)
An HTML element with a tag name, attributes, and children
Text(String)
Plain text content
Fragment(Vec<Node>)
A group of nodes without a wrapper element
Comment(String)
An HTML comment
Empty
Implementations§
Source§impl Node
impl Node
Sourcepub fn as_element_mut(&mut self) -> Option<&mut Element>
pub fn as_element_mut(&mut self) -> Option<&mut Element>
Attempts to get a mutable reference to the underlying Element if this node is an Element.
Returns None if the node is not an Element (e.g., if it’s Text or Fragment).
Sourcepub fn append_child(&mut self, node: Node)
pub fn append_child(&mut self, node: Node)
Adds a child node if this node is an Element.
This method has no effect if the node is not an Element.
Trait Implementations§
Source§impl FromIterator<i32> for Node
impl FromIterator<i32> for Node
Source§impl FromIterator<u32> for Node
impl FromIterator<u32> for Node
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnwindSafe for Node
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
Mutably borrows from an owned value. Read more