pub enum Mutation {
Show 16 variants AppendChildren { id: ElementId, m: usize, }, AssignId { path: &'static [u8], id: ElementId, }, CreatePlaceholder { id: ElementId, }, CreateTextNode { value: String, id: ElementId, }, HydrateText { path: &'static [u8], value: String, id: ElementId, }, LoadTemplate { name: &'static str, index: usize, id: ElementId, }, ReplaceWith { id: ElementId, m: usize, }, ReplacePlaceholder { path: &'static [u8], m: usize, }, InsertAfter { id: ElementId, m: usize, }, InsertBefore { id: ElementId, m: usize, }, SetAttribute { name: &'static str, ns: Option<&'static str>, value: AttributeValue, id: ElementId, }, SetText { value: String, id: ElementId, }, NewEventListener { name: String, id: ElementId, }, RemoveEventListener { name: String, id: ElementId, }, Remove { id: ElementId, }, PushRoot { id: ElementId, },
}
Expand description

A Mutation represents a single instruction for the renderer to use to modify the UI tree to match the state of the Dioxus VirtualDom.

These edits can be serialized and sent over the network or through any interface

Variants§

§

AppendChildren

Add these m children to the target element

Fields

§id: ElementId

The ID of the element being mounted to

§m: usize

The number of nodes on the stack to append to the target element

§

AssignId

Assign the element at the given path the target ElementId.

The path is in the form of a list of indices based on children. Templates cannot have more than 255 children per element, hence the use of a single byte.

Fields

§path: &'static [u8]

The path of the child of the topmost node on the stack

A path of [] represents the topmost node. A path of [0] represents the first child. [0,1,2] represents 1st child’s 2nd child’s 3rd child.

§id: ElementId

The ID we’re assigning to this element/placeholder.

This will be used later to modify the element or replace it with another element.

§

CreatePlaceholder

Create a placeholder in the DOM that we will use later.

Dioxus currently requires the use of placeholders to maintain a re-entrance point for things like list diffing

Fields

§id: ElementId

The ID we’re assigning to this element/placeholder.

This will be used later to modify the element or replace it with another element.

§

CreateTextNode

Create a node specifically for text with the given value

Fields

§value: String

The text content of this text node

§id: ElementId

The ID we’re assigning to this specific text nodes

This will be used later to modify the element or replace it with another element.

§

HydrateText

Hydrate an existing text node at the given path with the given text.

Assign this text node the given ID since we will likely need to modify this text at a later point

Fields

§path: &'static [u8]

The path of the child of the topmost node on the stack

A path of [] represents the topmost node. A path of [0] represents the first child. [0,1,2] represents 1st child’s 2nd child’s 3rd child.

§value: String

The value of the textnode that we want to set the placeholder with

§id: ElementId

The ID we’re assigning to this specific text nodes

This will be used later to modify the element or replace it with another element.

§

LoadTemplate

Load and clone an existing node from a template saved under that specific name

Dioxus guarantees that the renderer will have already been provided the template. When the template is picked up in the template list, it should be saved under its “name” - here, the name

Fields

§name: &'static str

The “name” of the template. When paired with rsx!, this is autogenerated

§index: usize

Which root are we loading from the template?

The template is stored as a list of nodes. This index represents the position of that root

§id: ElementId

The ID we’re assigning to this element being loaded from the template

This will be used later to move the element around in lists

§

ReplaceWith

Replace the target element (given by its ID) with the topmost m nodes on the stack

Fields

§id: ElementId

The ID of the node we’re going to replace with

§m: usize

The number of nodes on the stack to replace the target element with

§

ReplacePlaceholder

Replace an existing element in the template at the given path with the m nodes on the stack

Fields

§path: &'static [u8]

The path of the child of the topmost node on the stack

A path of [] represents the topmost node. A path of [0] represents the first child. [0,1,2] represents 1st child’s 2nd child’s 3rd child.

§m: usize

The number of nodes on the stack to replace the target element with

§

InsertAfter

Insert a number of nodes after a given node.

Fields

§id: ElementId

The ID of the node to insert after.

§m: usize

The number of nodes on the stack to insert after the target node.

§

InsertBefore

Insert a number of nodes before a given node.

Fields

§id: ElementId

The ID of the node to insert before.

§m: usize

The number of nodes on the stack to insert before the target node.

§

SetAttribute

Set the value of a node’s attribute.

Fields

§name: &'static str

The name of the attribute to set.

§ns: Option<&'static str>

The (optional) namespace of the attribute. For instance, “style” is in the “style” namespace.

§value: AttributeValue

The value of the attribute.

§id: ElementId

The ID of the node to set the attribute of.

§

SetText

Set the textcontent of a node.

Fields

§value: String

The textcontent of the node

§id: ElementId

The ID of the node to set the textcontent of.

§

NewEventListener

Create a new Event Listener.

Fields

§name: String

The name of the event to listen for.

§id: ElementId

The ID of the node to attach the listener to.

§

RemoveEventListener

Remove an existing Event Listener.

Fields

§name: String

The name of the event to remove.

§id: ElementId

The ID of the node to remove.

§

Remove

Remove a particular node from the DOM

Fields

§id: ElementId

The ID of the node to remove.

§

PushRoot

Push the given root node onto our stack.

Fields

§id: ElementId

The ID of the root node to push.

Trait Implementations§

source§

impl Debug for Mutation

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Mutation

source§

fn eq(&self, other: &Mutation) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Mutation

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

source§

fn super_from(input: T) -> O

Convert from a type to another type.
source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

source§

fn super_into(self) -> O

Convert from a type to another type.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more