Skip to main content

Engine

Struct Engine 

Source
pub struct Engine { /* private fields */ }
Expand description

The headless editing engine over the current queue line.

Implementations§

Source§

impl Engine

Source

pub fn load() -> Result<Self>

Load the current queue line into the engine, applying the TUI’s entry guards. Reuses edit’s scoping: the current queue line (an untracked branch opens as one provisional section over trunk). Refuses a forked line, a dirty worktree, and an empty queue.

This is headless — it never checks for a TTY. The non-TTY guard lives in the command layer (commands::tui) so that tests can drive load in-process without a terminal.

Source

pub const fn line(&self) -> &EditableLine

The loaded queue line: commit sequence and boundaries.

Source

pub fn launched_from(&self) -> &str

The branch the TUI was launched from.

Source

pub fn landing_branch(&self) -> &str

The branch HEAD is currently on (the exit landing point).

Source

pub fn queue_name(&self) -> &str

The queue name new branches are recorded under.

Source

pub const fn has_pending(&self) -> bool

Whether any operation is on the undo stack (drives the quit-guard).

Source

pub const fn changed(&self) -> bool

Whether any operation has mutated git this session.

Source

pub fn layout(&self) -> Vec<(String, String)>

The final branch chain, front → tip, as (parent, branch) pairs.

Source

pub fn dissolved_with_prs(&self) -> Vec<(String, u64)>

Branches that were present at load but have since been dissolved, and that carried a cached PR number — the exit summary warns about these.

Source

pub fn apply(&mut self, op: Operation) -> Result<Applied>

Apply an operation. Boundary edits, undo/redo, and reorder are handled here; the remaining history-rewriting variants land in later tickets.

Most operations return Applied::Done; a rewriting operation that conflicts returns Applied::Conflict with a rebase in progress (see Engine::undo_conflict / Engine::conflicted).

Source

pub const fn conflicted(&self) -> bool

Whether a conflicted operation is awaiting resolution.

Source

pub fn undo_conflict(&mut self) -> Result<()>

Back out a conflicted operation: abort the rebase and restore the pre-operation snapshot exactly.

Source

pub fn empty_branches(&self) -> Vec<usize>

Boundary indices whose branch currently owns no commits (e.g. after a delete emptied it) — the view offers to dissolve these.

Source

pub fn pr_of(&self, boundary: usize) -> Option<u64>

The cached PR number of the branch at boundary, if any. O(1) — no git call — so the view can call it every frame.

Source

pub fn branch_name(&self, boundary: usize) -> &str

The branch name at boundary.

Source

pub fn split_lines(&self, index: usize) -> Result<Vec<SplitLine>>

The split selector’s view of the commit at index: its diff flattened into displayable lines, the +/- ones carrying a dense change_index.

Source

pub fn split_change_count(&self, index: usize) -> Result<usize>

The number of selectable (+/-) lines in the commit at index.

Source

pub fn squash_needs_message(&self, index: usize) -> Result<bool>

Whether squashing the commit at index into its older neighbour needs a combined-message prompt — true only when both descriptions are non-empty (otherwise the non-empty side is used, or the result is empty).

Source

pub fn squash_default_message(&self, index: usize) -> Result<String>

The default combined description shown in the squash prompt: the older body then the newer, blank line between (each without its id trailer).

Trait Implementations§

Source§

impl Debug for Engine

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