Skip to main content

Module experimental_diff_renderer

Module experimental_diff_renderer 

Source
Expand description

§DiffRenderer (experimental_)

Runtime-agnostic diff-rendering trait. Plugins implement this to provide syntax-aware diff rendering; the host calls it without knowing whether the implementation is Lua, WASM, or native.

§Stability

This trait is experimental as of SDK 0.3. Once progit-syntax-diff v0.1 ships and exercises the API in production, it will be promoted to the stable traits::DiffRenderer namespace.

§Trait firewall

Implementations of this trait may be backed by Lua or WASM, but the trait itself MUST NOT reference mlua::* or wasmtime::* types. The TUI calls a Box<dyn DiffRenderer> and never sees the runtime.

§Design rationale

  • DiffRequest carries content, never paths — plugins do not perform I/O.
  • DiffResponse is fully serializable — crosses the Lua/WASM boundary as JSON without callbacks or closures.
  • TokenSpan reuse — diff coloring is a specialized case of token highlighting plus line-kind metadata.
  • max_lines truncation rather than streaming callbacks — Lua has no native async; the host calls render again with a larger budget for incremental display.

Structs§

DiffLine
One rendered line.
DiffRequest
Patch / diff input.
DiffResponse
Render result. A sequence of styled lines the host can render directly.

Enums§

DiffLineKind
DiffView
Render style.

Traits§

DiffRenderer
The runtime-agnostic trait the TUI calls.