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
impl UndoLog
pub fn new(doc: &mut AutoCommit) -> 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
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)
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>
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>
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
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
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>
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
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
pub fn redo_depth(&self, doc: &AutoCommit) -> usize
How many undos of this session redo can bring back.
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.
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
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.
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
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>
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>
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>
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>
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>
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>
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( &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_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§
Auto Trait Implementations§
impl !Freeze for UndoLog
impl !RefUnwindSafe for UndoLog
impl !Send for UndoLog
impl !Sync for UndoLog
impl Unpin for UndoLog
impl UnsafeUnpin for UndoLog
impl UnwindSafe for UndoLog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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