Trait rustc_ap_rustc_data_structures::undo_log::Snapshots [−][src]
pub trait Snapshots<T>: UndoLogs<T> { type Snapshot; fn actions_since_snapshot(&self, snapshot: &Self::Snapshot) -> &[T]ⓘ; fn start_snapshot(&mut self) -> Self::Snapshot; fn rollback_to<R>(
&mut self,
storage: impl FnOnce() -> R,
snapshot: Self::Snapshot
)
where
R: Rollback<T>; fn commit(&mut self, snapshot: Self::Snapshot); fn has_changes(&self, snapshot: &Self::Snapshot) -> bool { ... } }
Expand description
A trait which extends UndoLogs
to allow snapshots to be done at specific points. Each snapshot can then be used to
rollback any changes to an underlying data structures if they were not desirable.
Each snapshot must be consumed linearly with either rollback_to
or commit
.
Associated Types
Required methods
fn actions_since_snapshot(&self, snapshot: &Self::Snapshot) -> &[T]ⓘ
[src]
fn actions_since_snapshot(&self, snapshot: &Self::Snapshot) -> &[T]ⓘ
[src]Returns the slice of actions that were taken since the snapshot began.
fn start_snapshot(&mut self) -> Self::Snapshot
[src]
fn start_snapshot(&mut self) -> Self::Snapshot
[src]Starts a new snapshot. That snapshot must eventually either be committed via a call to commit or rollback via rollback_to. Snapshots can be nested (i.e., you can start a snapshot whilst another snapshot is in progress) but you must then commit or rollback the inner snapshot before attempting to commit or rollback the outer snapshot.
fn rollback_to<R>(
&mut self,
storage: impl FnOnce() -> R,
snapshot: Self::Snapshot
) where
R: Rollback<T>,
[src]
fn rollback_to<R>(
&mut self,
storage: impl FnOnce() -> R,
snapshot: Self::Snapshot
) where
R: Rollback<T>,
[src]Rollback (undo) the changes made to storage
since the snapshot.
Provided methods
fn has_changes(&self, snapshot: &Self::Snapshot) -> bool
[src]
fn has_changes(&self, snapshot: &Self::Snapshot) -> bool
[src]Returns true if self
has made any changes since snapshot started.
Implementations on Foreign Types
impl<'_, T, U> Snapshots<T> for &'_ mut U where
U: Snapshots<T>,
[src]
impl<'_, T, U> Snapshots<T> for &'_ mut U where
U: Snapshots<T>,
[src]type Snapshot = <U as Snapshots<T>>::Snapshot
pub fn has_changes(
&self,
snapshot: &<&'_ mut U as Snapshots<T>>::Snapshot
) -> bool
[src]
&self,
snapshot: &<&'_ mut U as Snapshots<T>>::Snapshot
) -> bool
pub fn actions_since_snapshot(
&self,
snapshot: &<&'_ mut U as Snapshots<T>>::Snapshot
) -> &[T]ⓘ
[src]
&self,
snapshot: &<&'_ mut U as Snapshots<T>>::Snapshot
) -> &[T]ⓘ
pub fn start_snapshot(&mut self) -> <&'_ mut U as Snapshots<T>>::Snapshot
[src]
pub fn rollback_to<R>(
&mut self,
storage: impl FnOnce() -> R,
snapshot: <&'_ mut U as Snapshots<T>>::Snapshot
) where
R: Rollback<T>,
[src]
&mut self,
storage: impl FnOnce() -> R,
snapshot: <&'_ mut U as Snapshots<T>>::Snapshot
) where
R: Rollback<T>,
pub fn commit(&mut self, snapshot: <&'_ mut U as Snapshots<T>>::Snapshot)
[src]
Implementors
impl<T> Snapshots<T> for VecLog<T>
[src]
impl<T> Snapshots<T> for VecLog<T>
[src]type Snapshot = Snapshot
pub fn has_changes(
&self,
snapshot: &<VecLog<T> as Snapshots<T>>::Snapshot
) -> bool
[src]
&self,
snapshot: &<VecLog<T> as Snapshots<T>>::Snapshot
) -> bool
pub fn actions_since_snapshot(&self, snapshot: &Snapshot) -> &[T]ⓘ
[src]
pub fn start_snapshot(&mut self) -> Snapshot
[src]
pub fn rollback_to<R>(&mut self, values: impl FnOnce() -> R, snapshot: Snapshot) where
R: Rollback<T>,
[src]
R: Rollback<T>,