plushie/patch
Patch operations for tree diffs.
Produced by tree.diff and consumed by protocol/encode to send
incremental updates to the Rust binary. Each operation targets a
node by its path – a list of integer child indices from the root.
For example, [0, 2] means “root’s first child, then that node’s
third child”.
Types
A single patch operation.
Operations match the Rust binary’s expected format:
replace_node: swap an entire subtreeupdate_props: merge changed props (removed keys set to null)insert_child: add a new child at a specific indexremove_child: remove a child at a specific index
pub type PatchOp {
ReplaceNode(path: List(Int), node: node.Node)
UpdateProps(
path: List(Int),
props: dict.Dict(String, node.PropValue),
)
InsertChild(path: List(Int), index: Int, node: node.Node)
RemoveChild(path: List(Int), index: Int)
}
Constructors
-
ReplaceNode(path: List(Int), node: node.Node)Replace the entire subtree at
pathwithnode. -
UpdateProps( path: List(Int), props: dict.Dict(String, node.PropValue), )Merge
propsinto the node atpath. Keys withNullValsignal removal. -
InsertChild(path: List(Int), index: Int, node: node.Node)Insert
nodeas a child atindexunder the node atpath. -
RemoveChild(path: List(Int), index: Int)Remove the child at
indexfrom the node atpath.