pub struct Node<E: Extension> { /* private fields */ }
Expand description
A node representing an element or text.
Can be cloned to duplicate the reference to the node.
Implementations§
source§impl<E: Extension> Node<E>
impl<E: Extension> Node<E>
sourcepub fn new<S>(name: S) -> Node<E>where
S: Into<String>,
pub fn new<S>(name: S) -> Node<E>where
S: Into<String>,
Creates a new element with the given name.
sourcepub fn new_text<S>(text: S) -> Node<E>where
S: Into<String>,
pub fn new_text<S>(text: S) -> Node<E>where
S: Into<String>,
Creates a new text node with the given text.
sourcepub fn borrow(&self) -> Ref<'_, NodeInner<E>>
pub fn borrow(&self) -> Ref<'_, NodeInner<E>>
Returns an immutable reference to the node’s inner value
sourcepub fn borrow_mut(&self) -> RefMut<'_, NodeInner<E>>
pub fn borrow_mut(&self) -> RefMut<'_, NodeInner<E>>
Returns an mutable reference to the node’s inner value
sourcepub fn add_child_first(&self, node: Node<E>) -> bool
pub fn add_child_first(&self, node: Node<E>) -> bool
Adds the passed node as a child to this node before other child nodes.
Returns true if the node was added
sourcepub fn add_child(&self, node: Node<E>) -> bool
pub fn add_child(&self, node: Node<E>) -> bool
Adds the passed node as a child to this node.
Returns true if the node was added
sourcepub fn remove_child(&self, node: Node<E>) -> bool
pub fn remove_child(&self, node: Node<E>) -> bool
Removes the passed node as a child from this node.
Returns true if the node was removed
sourcepub fn children(&self) -> Vec<Node<E>>
pub fn children(&self) -> Vec<Node<E>>
Returns a vector containing the child nodes of this node.
sourcepub fn is_same(&self, other: &Node<E>) -> bool
pub fn is_same(&self, other: &Node<E>) -> bool
Returns whether the passed node points to the same node as this one
sourcepub fn set_text<S>(&self, txt: S)where
S: Into<String>,
String: PartialEq<S>,
pub fn set_text<S>(&self, txt: S)where
S: Into<String>,
String: PartialEq<S>,
Sets the text of the node if it is a text node.
sourcepub fn has_layout(&self) -> bool
pub fn has_layout(&self) -> bool
Returns whether this node has had its layout computed at least once
sourcepub fn raw_position(&self) -> Rect
pub fn raw_position(&self) -> Rect
Returns the raw position of the node.
This position isn’t transformed and is relative
to the parent instead of absolute like render_position
sourcepub fn render_position(&self) -> Option<Rect>
pub fn render_position(&self) -> Option<Rect>
Returns the rendering position of the node.
Useful for IME handling.
Must be called after a layout
call.
sourcepub fn remove_property(&self, key: &str)
pub fn remove_property(&self, key: &str)
Removes the property on the node.
sourcepub fn get_property<V>(&self, key: &str) -> Option<V>where
V: ConvertValue<E>,
pub fn get_property<V>(&self, key: &str) -> Option<V>where
V: ConvertValue<E>,
Returns a copy of the value for the given property if it exists.
sourcepub fn get_property_ref<V>(&self, key: &str) -> Option<Ref<'_, V::RefType>>where
V: ConvertValue<E>,
pub fn get_property_ref<V>(&self, key: &str) -> Option<Ref<'_, V::RefType>>where
V: ConvertValue<E>,
Returns a reference to the value for the given property if it exists.
sourcepub fn set_property<V>(&self, key: &str, v: V)where
V: ConvertValue<E>,
pub fn set_property<V>(&self, key: &str, v: V)where
V: ConvertValue<E>,
Sets the value of a given property
sourcepub fn raw_set_property<V>(&self, key: &str, v: V)where
V: ConvertValue<E>,
pub fn raw_set_property<V>(&self, key: &str, v: V)where
V: ConvertValue<E>,
Sets the value of a given property without flagging the node as changed.
This is useful for when properties are use as storage and not used in style rules.
As a general convention this properties should use keys
begining with $
(e.g. $cycle
) as these are not accepted
by the style parser.
sourcepub fn from_document(desc: Document<'_>) -> Node<E>
pub fn from_document(desc: Document<'_>) -> Node<E>
Creates a node from a parsed document.