Expand description
Layout types and algorithms for diff rendering.
This module provides the infrastructure for formatting diffs with proper alignment, coloring, and collapsing of unchanged runs.
§Architecture
- Format phase: Walk the Diff, format all scalar values into
FormatArena - Layout phase: Build
LayoutNodetree, group attrs, calculate alignment - Render phase: Walk tree, emit to writer with prefixes/colors/padding
Structs§
- Ansi
Backend - ANSI backend - emits ANSI escape codes for terminal colors.
- Attr
- A single attribute with its formatting info.
- Build
Options - Options for building a layout from a diff.
- Changed
Group - A group of changed attributes that fit on one -/+ line pair.
- Format
Arena - Arena for formatted strings.
- Formatted
Value - A pre-formatted value with its measurements.
- Json
Flavor - JSON-style output flavor (JSONC with comments for type names).
- Layout
- The complete layout ready for rendering.
- Plain
Backend - Plain backend - no styling, just plain text.
- Render
Options - Options for rendering a layout.
- Rust
Flavor - Rust-style output flavor.
- Span
- A span into the format arena’s buffer.
- XmlFlavor
- XML-style output flavor.
Enums§
- Attr
Status - The change status of an attribute.
- Element
Change - How an element changed (affects its prefix and color).
- Field
Presentation - How a field should be presented in the diff output.
- Layout
Node - A node in the layout tree.
- Semantic
Color - Semantic color meaning for diff elements.
- Value
Type - Type of a formatted value for color selection.
Traits§
- Color
Backend - A backend that decides how to render semantic colors.
- Diff
Flavor - A diff output flavor that knows how to format values and present fields.
Functions§
- build_
layout - Build a Layout from a Diff.
- group_
changed_ attrs - Group changed attributes into lines that fit within max line width.
- render
- Render a layout to a writer.
- render_
to_ string - Render a layout to a String.