Skip to main content

Trail

Struct Trail 

Source
pub struct Trail {
    undo: Vec<Entry>,
    redo: Vec<Entry>,
    standing: Rev,
}
Expand description

Where a session’s history stands: what one press would take back, what one would put back, and which rev’s document the head currently holds.

Fields§

§undo: Vec<Entry>§redo: Vec<Entry>§standing: Rev

Implementations§

Source§

impl Trail

Source

pub fn standing(&self) -> Rev

The rev whose document the head holds. An edit at N stands at N; a step stands at the rev it restored, so an undo and its redo return the session to the position it started from rather than to a rev that merely looks like it.

Source

pub fn seeded(&mut self, rev: Rev)

Stand at rev with nothing new to take back: a commit that is the document’s past rather than a step this session took — the seeding path, and a repo built by folding a log before a session opened over it.

Without it the first edit over such a document would offer to restore the empty document, since that is where a fresh trail stands.

Source

pub fn record(&mut self, rev: Rev, journal_as: JournalAs)

Take a record of rev into the trail: an edit or a redo is a step somebody can take back, an undo is one they can put back, and each step retires the entry it consumed.

This is the only place the policy lives, so a live session and a replayed log cannot disagree about the trail they end up with.

Source

pub fn stepping( &self, edit: Rev, direction: Direction, ) -> Result<Entry, UndoRefusal>

The entry a step naming edit would take, without taking it.

§Errors

UndoRefusal::Spent when nothing stands ready, and UndoRefusal::Stale — reporting its own top — when the top is a different rev than edit.

Source

pub fn can_undo(&self) -> bool

Source

pub fn can_redo(&self) -> bool

Source

pub fn undo_depth(&self) -> usize

How many steps stand ready to be taken back. The editor keeps a parallel stack that interleaves view steps with these, and the two depths must agree — exposed so the mismatch is checkable rather than silent.

Source

pub fn redo_depth(&self) -> usize

Source

pub fn next_undo(&self) -> Option<Rev>

The rev an undo would move, and the one a redo would — so a caller holding its own history can tell whether the step it is about to take is still the step this trail would take.

Source

pub fn next_redo(&self) -> Option<Rev>

Source

pub fn undo_revs(&self) -> Vec<Rev>

Every rev standing ready to be taken back, oldest first — for a caller whose own stack must agree with this one, entry for entry.

Source

pub fn redo_revs(&self) -> Vec<Rev>

The forward half of Self::undo_revs.

Source

pub fn standings(&self) -> Vec<Rev>

Everywhere this trail can stand, deepest past first, with Self::standing at index Self::undo_depth — one point per step a walk from either end would take, which is what a session rebuilding its own stack from a reopened document needs.

Source

fn stack(&self, direction: Direction) -> &[Entry]

Source

fn stand_where(&mut self, retired: Option<Entry>)

Trait Implementations§

Source§

impl Clone for Trail

Source§

fn clone(&self) -> Trail

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Trail

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Trail

Source§

fn default() -> Trail

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Trail

Source§

fn eq(&self, other: &Trail) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Trail

Source§

impl StructuralPartialEq for Trail

Auto Trait Implementations§

§

impl Freeze for Trail

§

impl RefUnwindSafe for Trail

§

impl Send for Trail

§

impl Sync for Trail

§

impl Unpin for Trail

§

impl UnsafeUnpin for Trail

§

impl UnwindSafe for Trail

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.

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