pub trait WriteMutations {
Show 16 methods
// Required methods
fn push_id(&mut self, id: ElementId);
fn child(&mut self, index: usize);
fn pop(&mut self);
fn create_element(&mut self, tag: &str, ns: Option<&str>);
fn create_text(&mut self, value: &str);
fn clone(&mut self);
fn append_children(&mut self, m: usize);
fn replace_with(&mut self, m: usize);
fn insert_after(&mut self, m: usize);
fn insert_before(&mut self, m: usize);
fn set_attribute(
&mut self,
name: &str,
ns: Option<&str>,
value: &AttributeValue,
);
fn set_text(&mut self, value: &str);
fn add_event_listener(&mut self, name: &str);
fn remove_event_listener(&mut self, name: &str);
fn remove(&mut self);
fn set_id(&mut self, id: ElementId);
}Expand description
Something that can handle the mutations that are generated by the diffing process and apply them to the Real DOM
This object provides a stack-only stream of changes for a renderer to use to patch the Real DOM with the state of the VirtualDom.
These changes are specific to one subtree, so to patch multiple subtrees, you’d need to handle each set separately.
Mutations are the only link between the RealDOM and the VirtualDOM.
Required Methods§
Sourcefn create_element(&mut self, tag: &str, ns: Option<&str>)
fn create_element(&mut self, tag: &str, ns: Option<&str>)
Create an element and push it onto the stack.
Sourcefn create_text(&mut self, value: &str)
fn create_text(&mut self, value: &str)
Create a text node and push it onto the stack.
Sourcefn append_children(&mut self, m: usize)
fn append_children(&mut self, m: usize)
Append the top m nodes to the parent below them. Leaves the parent
on the stack.
Sourcefn replace_with(&mut self, m: usize)
fn replace_with(&mut self, m: usize)
Replace the target below the top m nodes with those nodes. Consumes
the target and replacement nodes.
Sourcefn insert_after(&mut self, m: usize)
fn insert_after(&mut self, m: usize)
Insert the top m nodes after the anchor below them. Leaves the anchor
on the stack.
Sourcefn insert_before(&mut self, m: usize)
fn insert_before(&mut self, m: usize)
Insert the top m nodes before the anchor below them. Leaves the anchor
on the stack.
Sourcefn set_attribute(
&mut self,
name: &str,
ns: Option<&str>,
value: &AttributeValue,
)
fn set_attribute( &mut self, name: &str, ns: Option<&str>, value: &AttributeValue, )
Set the value of a node’s attribute.
Name: The name of the attribute to set. NS: The (optional) namespace of the attribute. For instance, “style” is in the “style” namespace. Value: The value of the attribute.
Sourcefn set_text(&mut self, value: &str)
fn set_text(&mut self, value: &str)
Set the text content of a node.
Value: The textcontent of the node
Sourcefn add_event_listener(&mut self, name: &str)
fn add_event_listener(&mut self, name: &str)
Create a new Event Listener.
Name: The name of the event to listen for.
Sourcefn remove_event_listener(&mut self, name: &str)
fn remove_event_listener(&mut self, name: &str)
Remove an existing Event Listener.
Name: The name of the event to remove.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<W: WriteMutations + ?Sized> WriteMutations for &mut W
Forward through a mutable reference so writer-generic code can be
instantiated at &mut dyn WriteMutations.
impl<W: WriteMutations + ?Sized> WriteMutations for &mut W
Forward through a mutable reference so writer-generic code can be
instantiated at &mut dyn WriteMutations.