Skip to main content

CommitBuilder

Struct CommitBuilder 

Source
pub struct CommitBuilder {
    label: String,
    ops: Vec<OpCodes>,
}
Expand description

Accumulates one gesture’s ops into a sealed Commit. Push order is preserved verbatim — an op’s index is its Seq in the total write order, so the builder’s order is the merge-relevant order (and a pasted group’s internal stacking). Sealing consumes the builder, so a commit cannot be extended after the fact, and a gesture that edited nothing seals to None and submits nothing.

Deliberately blind to the document: dropping a non-edit (an update equal to what the document already holds) is the push site’s job — the op emitters can compare against the document, the builder cannot.

Fields§

§label: String§ops: Vec<OpCodes>

Implementations§

Source§

impl CommitBuilder

Source

pub fn new(label: impl Into<String>) -> Self

Start a gesture under its semantic label — a command’s stable name where a command triggered the edit, a tool-authored string otherwise.

Source

pub fn push(&mut self, op: OpCodes)

Append one op; its position becomes its Seq.

Source

pub fn extend(&mut self, ops: impl IntoIterator<Item = OpCodes>)

Append a run of ops in order, as Self::push would one by one.

Source

pub fn ops(&self) -> &[OpCodes]

What the gesture has pushed so far, without sealing. The one reader is a gesture that must see its own effect before it finishes — a solver rider folds these onto a scratch prediction, solves against it, and pushes the result here in turn.

Source

pub fn seal(self) -> Option<Commit>

Seal the gesture: None when nothing was pushed, else the commit with the ops exactly as pushed.

Trait Implementations§

Source§

impl Debug for CommitBuilder

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.