pub enum Mutation<'a> {
Show 16 variants AppendChildren { id: ElementId, m: usize, }, AssignId { path: &'static [u8], id: ElementId, }, CreatePlaceholder { id: ElementId, }, CreateTextNode { value: &'a str, id: ElementId, }, HydrateText { path: &'static [u8], value: &'a str, 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: &'a str, value: BorrowedAttributeValue<'a>, id: ElementId, ns: Option<&'a str>, }, SetText { value: &'a str, id: ElementId, }, NewEventListener { name: &'a str, id: ElementId, }, RemoveEventListener { name: &'a str, 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

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

Add these m children to the target element

§

AssignId

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.

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.

§

CreatePlaceholder

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.

Create an placeholder int he DOM that we will use later.

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

§

CreateTextNode

Fields

§value: &'a str

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.

Create a node specifically for text with the given value

§

HydrateText

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: &'a str

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.

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

§

LoadTemplate

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

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

§

ReplaceWith

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

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

§

ReplacePlaceholder

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

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

§

InsertAfter

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.

Insert a number of nodes after a given node.

§

InsertBefore

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.

Insert a number of nodes before a given node.

§

SetAttribute

Fields

§name: &'a str

The name of the attribute to set.

§value: BorrowedAttributeValue<'a>

The value of the attribute.

§id: ElementId

The ID of the node to set the attribute of.

§ns: Option<&'a str>

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

Set the value of a node’s attribute.

§

SetText

Fields

§value: &'a str

The textcontent of the node

§id: ElementId

The ID of the node to set the textcontent of.

Set the textcontent of a node.

§

NewEventListener

Fields

§name: &'a str

The name of the event to listen for.

§id: ElementId

The ID of the node to attach the listener to.

Create a new Event Listener.

§

RemoveEventListener

Fields

§name: &'a str

The name of the event to remove.

§id: ElementId

The ID of the node to remove.

Remove an existing Event Listener.

§

Remove

Fields

§id: ElementId

The ID of the node to remove.

Remove a particular node from the DOM

§

PushRoot

Fields

§id: ElementId

The ID of the root node to push.

Push the given root node onto our stack.

Trait Implementations§

source§

impl<'a> Debug for Mutation<'a>

source§

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

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

impl<'a> Deserialize<'static> for Mutation<'a>

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'static>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'a> PartialEq<Mutation<'a>> for Mutation<'a>

source§

fn eq(&self, other: &Mutation<'a>) -> 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<'a> Serialize for Mutation<'a>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<'a> StructuralPartialEq for Mutation<'a>

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Mutation<'a>

§

impl<'a> !Send for Mutation<'a>

§

impl<'a> !Sync for Mutation<'a>

§

impl<'a> Unpin for Mutation<'a>

§

impl<'a> !UnwindSafe for Mutation<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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