pub trait DiffParticipantSource:
Send
+ Sync
+ 'static
+ Debug {
// Required method
fn snapshot(&self) -> Rope;
// Provided method
fn buffer_id(&self) -> Option<BufferId> { ... }
}Expand description
One participant in a diff session — produces the rope to
diff for one slot in Hunk::ranges.
D.8.b (2026-05-31): collapses the previous
BaselineSource + CurrentSource two-trait split into a
single trait. The original split was structural sugar
(made descriptor.baseline.snapshot() vs
descriptor.current.snapshot() visually distinct) and
stopped scaling once participants became an arity-agnostic
Vec<Arc<dyn DiffParticipantSource>>. The slot index now
carries the role.
Concrete impls in this module:
StaticSource— owned in-memoryRope.OnDiskSource— re-reads a file at snapshot time.BufferSource— live rope from aBufferTextProvider- backed buffer.
D.7’s GitSource (post-implementation) will land alongside
these.
snapshot is called from inside the spawn_blocking body
of DiffSubsystem::schedule_recompute, so impls may do
cheap blocking I/O (a git cat-file for GitSource) but
must not hold the host’s UI thread. Send + Sync + 'static
is required so the trait object can cross the
spawn_blocking boundary.
Required Methods§
Provided Methods§
Sourcefn buffer_id(&self) -> Option<BufferId>
fn buffer_id(&self) -> Option<BufferId>
D.8.d (2026-05-31): the buffer id this source is
backed by, if any. Returns None for non-buffer
sources (StaticSource, OnDiskSource, future
GitSource); BufferSource overrides to return
Some(buffer_id).
Load-bearing for the slot ↔ buffer mapping the
subsystem’s membership API + the D.6.d
pane_index_of helper rely on. Without it,
compute_get_edit / compute_put_plan /
remove_participant_buffer would need a sidecar map
to find “the slot in Hunk::ranges for buffer X”.
Default None means non-overriding impls continue
to work — they just can’t be addressed by buffer id.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".