Skip to main content

DiffRenderer

Trait DiffRenderer 

Source
pub trait DiffRenderer {
    // Required methods
    fn provider_name(&self) -> &str;
    fn supported_languages(&self) -> Vec<String>;
    fn render(&mut self, request: &DiffRequest) -> PluginResult<DiffResponse>;
}
Expand description

The runtime-agnostic trait the TUI calls.

Plugins implement this. The SDK glue maps it onto Lua / WASM bindings behind opaque types. The TUI sees only Box<dyn DiffRenderer>.

Required Methods§

Source

fn provider_name(&self) -> &str

Returns the unique provider name. Must match the plugin manifest’s name field for routing.

Source

fn supported_languages(&self) -> Vec<String>

Returns the languages this renderer can handle. Use vec!["*".into()] for any-language fallback.

Source

fn render(&mut self, request: &DiffRequest) -> PluginResult<DiffResponse>

Render a diff.

Host caches by (hash(old_content), hash(new_content), language, view, word_diff). On cache miss the implementation must respond promptly — keep work linear in (old_content.len() + new_content.len()) and avoid I/O.

For very large diffs the host calls this repeatedly with growing max_lines and uses the truncated flag to know when to ask for more.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§