Skip to main content

DiffDescriptor

Struct DiffDescriptor 

Source
pub struct DiffDescriptor {
    pub sources: Vec<Arc<dyn DiffParticipantSource>>,
    pub watch: Vec<BufferId>,
    pub participants: Vec<BufferId>,
}
Expand description

The “what to diff against what” pair for a session.

sources is an arity-agnostic vector of N participant sources, one per slot in Hunk::ranges. The engine (crate::compute_diff) dispatches by sources.len() — N=2 is two-way (slot 0 = baseline / from, slot 1 = current / to), N=3 is three-way merge (slot 0 = base, slot 1 = local, slot 2 = remote), N≥4 returns DiffEngineError::Unsupported in v1.

watch is the explicit dependency declaration: every [BufferId] whose edits should wake this session. The descriptor’s author (a future :diffsplit / :Gdiff / AI-host call site) knows which sources are buffer-backed and contributes those BufferIds into watch. Static or git-blob sources contribute nothing.

Clone because the runtime sometimes wants a stable snapshot of the descriptor to feed a debounced recompute — the inner Vec<Arc<dyn ...>> and Vec<BufferId> clones are cheap (one Arc bump per source + a small heap allocation).

D.8.c shape (2026-05-31). Replaces the prior baseline + current + Option<remote> named-field triple with a single sources: Vec<...>; see [docs/dev/architecture/n-way-diff-membership.md] (docs/dev/architecture/n-way-diff-membership.md) for the rationale.

Fields§

§sources: Vec<Arc<dyn DiffParticipantSource>>

N participant sources in slot order. sources[i] produces the rope at Hunk::ranges[i] after a recompute. v1 supports N ∈ {1, 2, 3}; the engine returns DiffEngineError::Unsupported for N≥4.

§watch: Vec<BufferId>§participants: Vec<BufferId>

D.5.a (2026-05-30): user-visible diff sides that should receive diff-mode activation while this session is registered. Distinct from Self::watch:

  • watch declares edit-event subscriptions.
  • participants declares which buffers are user-visible diff sides that should get the mode toggle.

For buffer-backed sources they coincide; they diverge when a baseline source contributes no live buffer (file-on-disk inline → [primary]; D.7 git baseline → [primary]). Two-pane is [baseline, primary]; D.6 three-way is [base, local, remote] (length 3).

Implementations§

Source§

impl DiffDescriptor

Source

pub fn arity(&self) -> usize

D.8.c (2026-05-31): the session’s arity — the source of truth for how many participants this session has. Equivalent to sources.len().

Trait Implementations§

Source§

impl Clone for DiffDescriptor

Source§

fn clone(&self) -> DiffDescriptor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DiffDescriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more