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 subtree
  • update_props: merge changed props (removed keys set to null)
  • insert_child: add a new child at a specific index
  • remove_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 path with node.

  • UpdateProps(
      path: List(Int),
      props: dict.Dict(String, node.PropValue),
    )

    Merge props into the node at path. Keys with NullVal signal removal.

  • InsertChild(path: List(Int), index: Int, node: node.Node)

    Insert node as a child at index under the node at path.

  • RemoveChild(path: List(Int), index: Int)

    Remove the child at index from the node at path.

Search Document