Emerge.Engine.Patch (Emerge v0.1.0)

Copy Markdown View Source

Diff and encode patch operations for Emerge.Engine.Element trees.

Summary

Functions

Decode a binary command stream into patches.

Compute patches between two trees (expects numeric ids).

Encode patches into a binary command stream.

Types

nearby_slot()

@type nearby_slot() :: :behind | :above | :on_right | :below | :on_left | :in_front

patch()

@type patch() ::
  {:set_attrs, term(), map()}
  | {:set_children, term(), [term()]}
  | {:set_nearby_mounts, term(), [{nearby_slot(), term()}]}
  | {:insert_subtree, term() | nil, non_neg_integer(),
     Emerge.Engine.Element.t()}
  | {:insert_nearby_subtree, term(), non_neg_integer(), nearby_slot(),
     Emerge.Engine.Element.t()}
  | {:remove, term()}

Functions

decode(binary)

@spec decode(binary()) :: [patch()]

Decode a binary command stream into patches.

diff(old_tree, new_tree)

Compute patches between two trees (expects numeric ids).

encode(patches)

@spec encode([patch()]) :: binary()

Encode patches into a binary command stream.