Trait Renderer
pub trait Renderer:
Sized
+ Send
+ Debug
+ 'static {
type Node: Mountable + Clone + 'static;
type Element: AsRef<Self::Node> + CastFrom<Self::Node> + Mountable + Clone + 'static;
type Text: AsRef<Self::Node> + CastFrom<Self::Node> + Mountable + Clone + 'static;
type Placeholder: AsRef<Self::Node> + CastFrom<Self::Node> + Mountable + Clone + 'static;
Show 14 methods
// Required methods
fn intern(text: &str) -> &str;
fn create_text_node(text: &str) -> Self::Text;
fn create_placeholder() -> Self::Placeholder;
fn set_text(node: &Self::Text, text: &str);
fn set_attribute(node: &Self::Element, name: &str, value: &str);
fn remove_attribute(node: &Self::Element, name: &str);
fn insert_node(
parent: &Self::Element,
new_child: &Self::Node,
marker: Option<&Self::Node>,
);
fn remove_node(
parent: &Self::Element,
child: &Self::Node,
) -> Option<Self::Node>;
fn clear_children(parent: &Self::Element);
fn remove(node: &Self::Node);
fn get_parent(node: &Self::Node) -> Option<Self::Node>;
fn first_child(node: &Self::Node) -> Option<Self::Node>;
fn next_sibling(node: &Self::Node) -> Option<Self::Node>;
fn log_node(node: &Self::Node);
}Expand description
Implements the instructions necessary to render an interface on some platform.
By default, this is implemented for the Document Object Model (DOM) in a Web browser, but implementing this trait for some other platform allows you to use the library to render any tree-based UI.
Required Associated Types§
type Element: AsRef<Self::Node> + CastFrom<Self::Node> + Mountable + Clone + 'static
type Element: AsRef<Self::Node> + CastFrom<Self::Node> + Mountable + Clone + 'static
A visible element in the view tree.
Required Methods§
fn intern(text: &str) -> &str
fn intern(text: &str) -> &str
Interns a string slice, if that is available on this platform and useful as an optimization.
fn create_text_node(text: &str) -> Self::Text
fn create_text_node(text: &str) -> Self::Text
Creates a new text node.
fn create_placeholder() -> Self::Placeholder
fn create_placeholder() -> Self::Placeholder
Creates a new placeholder node.
fn set_text(node: &Self::Text, text: &str)
fn set_text(node: &Self::Text, text: &str)
Sets the text content of the node. If it’s not a text node, this does nothing.
fn set_attribute(node: &Self::Element, name: &str, value: &str)
fn set_attribute(node: &Self::Element, name: &str, value: &str)
Sets the given attribute on the given node by key and value.
fn remove_attribute(node: &Self::Element, name: &str)
fn remove_attribute(node: &Self::Element, name: &str)
Removes the given attribute on the given node.
fn insert_node(
parent: &Self::Element,
new_child: &Self::Node,
marker: Option<&Self::Node>,
)
fn insert_node( parent: &Self::Element, new_child: &Self::Node, marker: Option<&Self::Node>, )
Appends the new child to the parent, before the anchor node. If anchor is None,
append to the end of the parent’s children.
fn remove_node(parent: &Self::Element, child: &Self::Node) -> Option<Self::Node>
fn remove_node(parent: &Self::Element, child: &Self::Node) -> Option<Self::Node>
Removes the child node from the parents, and returns the removed node.
fn clear_children(parent: &Self::Element)
fn clear_children(parent: &Self::Element)
Removes all children from the parent element.
fn get_parent(node: &Self::Node) -> Option<Self::Node>
fn get_parent(node: &Self::Node) -> Option<Self::Node>
Gets the parent of the given node, if any.
fn first_child(node: &Self::Node) -> Option<Self::Node>
fn first_child(node: &Self::Node) -> Option<Self::Node>
Returns the first child node of the given node, if any.
fn next_sibling(node: &Self::Node) -> Option<Self::Node>
fn next_sibling(node: &Self::Node) -> Option<Self::Node>
Returns the next sibling of the given node, if any.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".