Skip to main content

UndoLog

Struct UndoLog 

pub struct UndoLog { /* private fields */ }
Expand description

A document’s undo, as one window drives it. See the module docs.

Implementations§

§

impl UndoLog

pub fn new(doc: &mut AutoCommit) -> UndoLog

A history over doc as it stands. The current heads become the baseline the next step brackets against, so content already in the document is not attributed to a step nobody took here.

pub fn revision(&self) -> u64

A counter that changes whenever the history this window drives moves, and never otherwise: the cheap “did anything change?” test for an Undo control.

pub fn rebase(&mut self, doc: &mut AutoCommit)

Re-baseline against the document’s current heads: what a merge of remote changes needs, so the next local step brackets against the merged picture. A step open before the merge ends at it.

pub fn next_undo_as( &self, doc: &AutoCommit, author: Option<&UserId>, ) -> Option<UndoEntry>

The step a Ctrl+Z by author would take back, without taking it back. With an author, other people’s steps are walked past; without one, any step of this session.

pub fn next_redo_as( &self, doc: &AutoCommit, author: Option<&UserId>, ) -> Option<UndoEntry>

The undo a Ctrl+Shift+Z by author would bring back. The entry brackets the undo change; the caret is where it was when the undo was taken.

pub fn can_undo_as(&self, doc: &AutoCommit, author: Option<&UserId>) -> bool

Whether author has anything to undo — true exactly when undo_as would take a step back.

pub fn can_redo_as(&self, doc: &AutoCommit, author: Option<&UserId>) -> bool

Whether author has anything to redo.

pub fn peek_last_undo(&self, doc: &AutoCommit) -> Option<UndoEntry>

The newest step of this session in effect, whoever made it.

pub fn undo_depth(&self, doc: &AutoCommit) -> usize

How many steps of this session are in effect, whoever made them.

pub fn redo_depth(&self, doc: &AutoCommit) -> usize

How many undos of this session redo can bring back.

pub fn commit_action_authored( &mut self, doc: &mut AutoCommit, focused_node_idx: Option<usize>, metadata: Option<String>, author: Option<UserId>, ) -> bool

Commit doc’s open transaction as a step, bracketed from the last boundary. Returns true iff this committed a change (there were pending ops). false means the transaction was empty — the caller can then skip any persistence / broadcast work.

pub fn commit_action_authored_with_message( &mut self, doc: &mut AutoCommit, focused_node_idx: Option<usize>, metadata: Option<String>, author: Option<UserId>, message: Option<String>, ) -> bool

As Self::commit_action_authored, with the entry of native CRDT edits that deliberately do not travel through an action envelope (for example, co-edited flowing text).

pub fn record_committed_action( &mut self, doc: &mut AutoCommit, before: Vec<ChangeHash>, focused_node_idx: Option<usize>, metadata: Option<String>, ) -> bool

Record a step already committed into doc out of band (an action the palette dispatched, which owns its own commit boundary), bracketed by before. Unattributed: an author-scoped Ctrl+Z of this session claims it.

pub fn record_committed_action_authored( &mut self, doc: &mut AutoCommit, before: Vec<ChangeHash>, focused_node_idx: Option<usize>, metadata: Option<String>, author: Option<UserId>, ) -> bool

As Self::record_committed_action, naming who performed it — for a change that reached this document from outside the window (an agent, a collaborator’s published operation) under the caller’s own actor. The name keeps the steps apart afterwards.

pub fn record_committed_action_in( &mut self, doc: &mut AutoCommit, before: Vec<ChangeHash>, focused_node_idx: Option<usize>, metadata: Option<String>, author: UserId, instance: u64, ) -> bool

Record a bound action of one window instance.

pub fn undo_as( &mut self, doc: &mut AutoCommit, author: Option<&UserId>, focus: Option<usize>, metadata: Option<String>, registry: Option<&ActionRegistry>, ) -> Option<UndoEntry>

Take back the step author would undo (see State::undo_as).

pub fn redo_as( &mut self, doc: &mut AutoCommit, author: Option<&UserId>, focus: Option<usize>, metadata: Option<String>, registry: Option<&ActionRegistry>, ) -> Option<UndoEntry>

Bring back the undo author would redo.

pub fn next_undo_in( &self, doc: &AutoCommit, author: &UserId, instance: u64, ) -> Option<UndoEntry>

The step author’s window instance would undo.

pub fn next_redo_in( &self, doc: &AutoCommit, author: &UserId, instance: u64, ) -> Option<UndoEntry>

The undo author’s window instance would redo.

pub fn undo_in( &mut self, doc: &mut AutoCommit, author: &UserId, instance: u64, focus: Option<usize>, metadata: Option<String>, registry: Option<&ActionRegistry>, ) -> Option<UndoEntry>

Take back the step author’s window instance would undo.

pub fn redo_in( &mut self, doc: &mut AutoCommit, author: &UserId, instance: u64, focus: Option<usize>, metadata: Option<String>, registry: Option<&ActionRegistry>, ) -> Option<UndoEntry>

Bring back the undo author’s window instance would redo.

pub fn restore_to_heads( &mut self, doc: &mut AutoCommit, target_heads: &[ChangeHash], focused_node_idx: Option<usize>, metadata: Option<String>, author: Option<UserId>, ) -> bool

pub fn restore_to_heads_with_message( &mut self, doc: &mut AutoCommit, target_heads: &[ChangeHash], focused_node_idx: Option<usize>, metadata: Option<String>, author: Option<UserId>, message: Option<String>, ) -> bool

pub fn restore_to_heads_in( &mut self, doc: &mut AutoCommit, target_heads: &[ChangeHash], focused_node_idx: Option<usize>, metadata: Option<String>, author: UserId, instance: u64, ) -> bool

Trait Implementations§

§

impl Default for UndoLog

§

fn default() -> UndoLog

A history with no baseline yet, for a holder that swaps a document’s own in and out.

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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
§

impl<T> ErasedDestructor for T
where T: 'static,