Skip to main content

WriteMutations

Trait WriteMutations 

Source
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§

Source

fn push_id(&mut self, id: ElementId)

Push the node registered to id onto the stack.

Source

fn child(&mut self, index: usize)

Replace the current top node with its indexth child.

Source

fn pop(&mut self)

Pop and discard the current top node.

Source

fn create_element(&mut self, tag: &str, ns: Option<&str>)

Create an element and push it onto the stack.

Source

fn create_text(&mut self, value: &str)

Create a text node and push it onto the stack.

Source

fn clone(&mut self)

Replace the current top node with a deep clone of itself.

Source

fn append_children(&mut self, m: usize)

Append the top m nodes to the parent below them. Leaves the parent on the stack.

Source

fn replace_with(&mut self, m: usize)

Replace the target below the top m nodes with those nodes. Consumes the target and replacement nodes.

Source

fn insert_after(&mut self, m: usize)

Insert the top m nodes after the anchor below them. Leaves the anchor on the stack.

Source

fn insert_before(&mut self, m: usize)

Insert the top m nodes before the anchor below them. Leaves the anchor on the stack.

Source

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.

Source

fn set_text(&mut self, value: &str)

Set the text content of a node.

Value: The textcontent of the node

Source

fn add_event_listener(&mut self, name: &str)

Create a new Event Listener.

Name: The name of the event to listen for.

Source

fn remove_event_listener(&mut self, name: &str)

Remove an existing Event Listener.

Name: The name of the event to remove.

Source

fn remove(&mut self)

Remove the current top node from the DOM and consume it.

Source

fn set_id(&mut self, id: ElementId)

Register the current top node under id, leaving it on the stack.

Replaces the old pop_id (which registered and popped): callers that want the node gone follow with pop, and freshly-created nodes that will be appended just stay on the stack.

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.

Source§

fn push_id(&mut self, id: ElementId)

Source§

fn child(&mut self, index: usize)

Source§

fn pop(&mut self)

Source§

fn create_element(&mut self, tag: &str, ns: Option<&str>)

Source§

fn create_text(&mut self, value: &str)

Source§

fn clone(&mut self)

Source§

fn append_children(&mut self, m: usize)

Source§

fn replace_with(&mut self, m: usize)

Source§

fn insert_after(&mut self, m: usize)

Source§

fn insert_before(&mut self, m: usize)

Source§

fn set_attribute( &mut self, name: &str, ns: Option<&str>, value: &AttributeValue, )

Source§

fn set_text(&mut self, value: &str)

Source§

fn add_event_listener(&mut self, name: &str)

Source§

fn remove_event_listener(&mut self, name: &str)

Source§

fn remove(&mut self)

Source§

fn set_id(&mut self, id: ElementId)

Implementors§