[−]Enum sauron::prelude::mt_dom::Patch
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
InsertNode(InsertNode<'a, NS, TAG, ATT, VAL, EVENT, MSG>)
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
AppendChildren(AppendChildren<'a, NS, TAG, ATT, VAL, EVENT, MSG>)
Append a vector of child nodes to a parent node id.
RemoveNode(RemoveNode<'a, TAG>)
remove node
ReplaceNode(ReplaceNode<'a, NS, TAG, ATT, VAL, EVENT, MSG>)
ReplaceNode a node with another node. This typically happens when a node's tag changes. ex:
AddAttributes(AddAttributes<'a, NS, TAG, ATT, VAL, EVENT, MSG>)
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
RemoveAttributes(RemoveAttributes<'a, NS, TAG, ATT, VAL, EVENT, MSG>)
Remove attributes that the old node had that the new node doesn't
ChangeText(ChangeText<'a>)
Change the text of a Text node.
Implementations
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
pub fn node_idx(&self) -> usize
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.
pub fn tag(&self) -> Option<&TAG>
return the tag of this patch
pub fn priority(&self) -> usize
prioritize patches, patches that doesn't change the NodeIdx in the actual DOM tree will be executed first.
Trait Implementations
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> Debug for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG> where
ATT: Debug,
NS: Debug,
TAG: Debug,
VAL: Debug,
ATT: Debug,
NS: Debug,
TAG: Debug,
VAL: Debug,
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> From<AddAttributes<'a, NS, TAG, ATT, VAL, EVENT, MSG>> for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
pub fn from(
at: AddAttributes<'a, NS, TAG, ATT, VAL, EVENT, MSG>
) -> Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
at: AddAttributes<'a, NS, TAG, ATT, VAL, EVENT, MSG>
) -> Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> From<AppendChildren<'a, NS, TAG, ATT, VAL, EVENT, MSG>> for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
pub fn from(
ac: AppendChildren<'a, NS, TAG, ATT, VAL, EVENT, MSG>
) -> Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
ac: AppendChildren<'a, NS, TAG, ATT, VAL, EVENT, MSG>
) -> Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> From<ChangeText<'a>> for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
pub fn from(ct: ChangeText<'a>) -> Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> From<InsertNode<'a, NS, TAG, ATT, VAL, EVENT, MSG>> for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
pub fn from(
ic: InsertNode<'a, NS, TAG, ATT, VAL, EVENT, MSG>
) -> Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
ic: InsertNode<'a, NS, TAG, ATT, VAL, EVENT, MSG>
) -> Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> From<RemoveAttributes<'a, NS, TAG, ATT, VAL, EVENT, MSG>> for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
pub fn from(
rt: RemoveAttributes<'a, NS, TAG, ATT, VAL, EVENT, MSG>
) -> Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
rt: RemoveAttributes<'a, NS, TAG, ATT, VAL, EVENT, MSG>
) -> Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> From<RemoveNode<'a, TAG>> for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
pub fn from(rc: RemoveNode<'a, TAG>) -> Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> From<ReplaceNode<'a, NS, TAG, ATT, VAL, EVENT, MSG>> for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
pub fn from(
rn: ReplaceNode<'a, NS, TAG, ATT, VAL, EVENT, MSG>
) -> Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
rn: ReplaceNode<'a, NS, TAG, ATT, VAL, EVENT, MSG>
) -> Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> PartialEq<Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>> for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG> where
ATT: PartialEq<ATT>,
EVENT: PartialEq<EVENT>,
MSG: PartialEq<MSG>,
NS: PartialEq<NS>,
TAG: PartialEq<TAG>,
VAL: PartialEq<VAL>,
ATT: PartialEq<ATT>,
EVENT: PartialEq<EVENT>,
MSG: PartialEq<MSG>,
NS: PartialEq<NS>,
TAG: PartialEq<TAG>,
VAL: PartialEq<VAL>,
pub fn eq(&self, other: &Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>) -> bool
pub fn ne(&self, other: &Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>) -> bool
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> StructuralPartialEq for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
Auto Trait Implementations
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> !RefUnwindSafe for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> !Send for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> !Sync for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> Unpin for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> !UnwindSafe for Patch<'a, NS, TAG, ATT, VAL, EVENT, MSG>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow(&self) -> &TⓘNotable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
Notable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut TⓘNotable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
Notable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,