Enum mt_dom::patch::Patch [−][src]
pub enum Patch<'a, NS, TAG, ATT, VAL, EVENT> where
NS: PartialEq + Clone + Debug,
TAG: PartialEq + Clone + Debug,
ATT: PartialEq + Clone + Debug,
VAL: PartialEq + Clone + Debug,
EVENT: PartialEq + Clone + Debug, { InsertNode(InsertNode<'a, NS, TAG, ATT, VAL, EVENT>), AppendChildren(AppendChildren<'a, NS, TAG, ATT, VAL, EVENT>), RemoveNode(RemoveNode<'a, TAG>), ReplaceNode(ReplaceNode<'a, NS, TAG, ATT, VAL, EVENT>), AddAttributes(AddAttributes<'a, NS, TAG, ATT, VAL, EVENT>), RemoveAttributes(RemoveAttributes<'a, NS, TAG, ATT, VAL, EVENT>), ChangeText(ChangeText<'a>), }
Expand description
A Patch encodes an operation that modifies a real DOM element or native UI element
To update the real DOM that a user sees you’ll want to first diff your old virtual dom and new virtual dom.
This diff operation will generate Vec<Patch>
with zero or more patches that, when
applied to your real DOM, will make your real DOM look like your new virtual dom.
Each Patch has a usize node index that helps us identify the real DOM node that it applies to.
Our old virtual dom’s nodes are indexed depth first, as shown in this illustration (0 being the root node, 1 being it’s first child, 2 being it’s first child’s first child).
.─. ( 0 ) `-' / \ / \ / \ ▼ ▼ .─. .─. ( 1 ) ( 4 ) `-' `-' / \ | \ '. / \ | \ '. ▼ ▼ | \ '. .─. .─. ▼ ▼ ▼ ( 2 ) ( 3 ) .─. .─. .─. `─' `─' ( 5 ) ( 6 ) ( 7 ) `─' `─' `─'
Variants
Insert a vector of child nodes to the current node being patch. The usize is the index of of the children of the node to be patch to insert to. The new children will be inserted before this usize
Tuple Fields of InsertNode
0: InsertNode<'a, NS, TAG, ATT, VAL, EVENT>
Append a vector of child nodes to a parent node id.
Tuple Fields of AppendChildren
0: AppendChildren<'a, NS, TAG, ATT, VAL, EVENT>
remove node
Tuple Fields of RemoveNode
0: RemoveNode<'a, TAG>
ReplaceNode a node with another node. This typically happens when a node’s tag changes. ex:
Tuple Fields of ReplaceNode
0: ReplaceNode<'a, NS, TAG, ATT, VAL, EVENT>
Add attributes that the new node has that the old node does not Note: the attributes is not a reference since attributes of same name are merged to produce a new unify attribute
Tuple Fields of AddAttributes
0: AddAttributes<'a, NS, TAG, ATT, VAL, EVENT>
Remove attributes that the old node had that the new node doesn’t
Tuple Fields of RemoveAttributes
0: RemoveAttributes<'a, NS, TAG, ATT, VAL, EVENT>
Change the text of a Text node.
Tuple Fields of ChangeText
0: ChangeText<'a>
Implementations
Every Patch is meant to be applied to a specific node within the DOM. Get the index of the DOM node that this patch should apply to. DOM nodes are indexed depth first with the root node in the tree having index 0.
Trait Implementations
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
impl<'a, NS: PartialEq, TAG: PartialEq, ATT: PartialEq, VAL: PartialEq, EVENT: PartialEq> PartialEq<Patch<'a, NS, TAG, ATT, VAL, EVENT>> for Patch<'a, NS, TAG, ATT, VAL, EVENT> where
NS: PartialEq + Clone + Debug,
TAG: PartialEq + Clone + Debug,
ATT: PartialEq + Clone + Debug,
VAL: PartialEq + Clone + Debug,
EVENT: PartialEq + Clone + Debug,
impl<'a, NS: PartialEq, TAG: PartialEq, ATT: PartialEq, VAL: PartialEq, EVENT: PartialEq> PartialEq<Patch<'a, NS, TAG, ATT, VAL, EVENT>> for Patch<'a, NS, TAG, ATT, VAL, EVENT> where
NS: PartialEq + Clone + Debug,
TAG: PartialEq + Clone + Debug,
ATT: PartialEq + Clone + Debug,
VAL: PartialEq + Clone + Debug,
EVENT: PartialEq + Clone + Debug,
Auto Trait Implementations
impl<'a, NS, TAG, ATT, VAL, EVENT> RefUnwindSafe for Patch<'a, NS, TAG, ATT, VAL, EVENT> where
ATT: RefUnwindSafe,
EVENT: RefUnwindSafe,
NS: RefUnwindSafe,
TAG: RefUnwindSafe,
VAL: RefUnwindSafe,
impl<'a, NS, TAG, ATT, VAL, EVENT> Send for Patch<'a, NS, TAG, ATT, VAL, EVENT> where
ATT: Sync,
EVENT: Sync,
NS: Sync,
TAG: Sync,
VAL: Sync,
impl<'a, NS, TAG, ATT, VAL, EVENT> Sync for Patch<'a, NS, TAG, ATT, VAL, EVENT> where
ATT: Sync,
EVENT: Sync,
NS: Sync,
TAG: Sync,
VAL: Sync,
impl<'a, NS, TAG, ATT, VAL, EVENT> UnwindSafe for Patch<'a, NS, TAG, ATT, VAL, EVENT> where
ATT: RefUnwindSafe,
EVENT: RefUnwindSafe,
NS: RefUnwindSafe,
TAG: RefUnwindSafe,
VAL: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more