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§
Sourcetype 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§
Sourcefn 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.
Sourcefn create_text_node(text: &str) -> Self::Text
fn create_text_node(text: &str) -> Self::Text
Creates a new text node.
Sourcefn create_placeholder() -> Self::Placeholder
fn create_placeholder() -> Self::Placeholder
Creates a new placeholder node.
Sourcefn 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.
Sourcefn 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.
Sourcefn remove_attribute(node: &Self::Element, name: &str)
fn remove_attribute(node: &Self::Element, name: &str)
Removes the given attribute on the given node.
Sourcefn 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.
Sourcefn 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.
Sourcefn clear_children(parent: &Self::Element)
fn clear_children(parent: &Self::Element)
Removes all children from the parent element.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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", so this trait is not object safe.