Enum Node

Source
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

Source

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

Source

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 Display for Node

Source§

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

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

impl From<&&str> for Node

Source§

fn from(value: &&str) -> Self

Converts to this type from the input type.
Source§

impl From<&String> for Node

Source§

fn from(value: &String) -> Self

Converts to this type from the input type.
Source§

impl From<&Vec<String>> for Node

Source§

fn from(value: &Vec<String>) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Node

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl<I, F, R> From<Map<I, F>> for Node
where I: Iterator, F: FnMut(I::Item) -> R, R: Into<Node>, Vec<Node>: FromIterator<R>,

Source§

fn from(iter: Map<I, F>) -> Self

Converts to this type from the input type.
Source§

impl<T: ToString> From<Option<T>> for Node

Source§

fn from(value: Option<T>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Node

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Vec<T>> for Node
where Node: From<T>,

Source§

fn from(value: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Node

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Node

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Node

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Node

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Node

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<i32> for Node

Source§

fn from_iter<T: IntoIterator<Item = i32>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<u32> for Node

Source§

fn from_iter<T: IntoIterator<Item = u32>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<u64> for Node

Source§

fn from_iter<T: IntoIterator<Item = u64>>(iter: T) -> Self

Creates a value from an iterator. 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 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> Attribute for T
where T: ToString,

Source§

fn value(&self) -> String

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.