pub struct ChangeTracker { /* private fields */ }Expand description
Concrete helper that stores original, current, and previous attribute values.
Implementations§
Source§impl ChangeTracker
impl ChangeTracker
Sourcepub fn track_change(&mut self, name: &str, old: Value, new: Value)
pub fn track_change(&mut self, name: &str, old: Value, new: Value)
Tracks a change from old to new for the named attribute.
If the attribute has already changed, the original value is preserved.
If new matches the original value, the attribute is removed from the
current change set.
Sourcepub fn previous_changes(&self) -> &HashMap<String, [Value; 2]>
pub fn previous_changes(&self) -> &HashMap<String, [Value; 2]>
Returns the previously applied changes.
Sourcepub fn attribute_changed(&self, name: &str) -> bool
pub fn attribute_changed(&self, name: &str) -> bool
Returns true when the named attribute is currently changed.
Sourcepub fn attribute_was(&self, name: &str) -> Option<&Value>
pub fn attribute_was(&self, name: &str) -> Option<&Value>
Returns the original value for the named changed attribute.
Sourcepub fn restore_attribute(&mut self, name: &str) -> Option<Value>
pub fn restore_attribute(&mut self, name: &str) -> Option<Value>
Restores a single attribute by removing it from the tracked changes.
The returned value is the original value that callers should write back to the underlying attribute storage.
Trait Implementations§
Source§impl Clone for ChangeTracker
impl Clone for ChangeTracker
Source§fn clone(&self) -> ChangeTracker
fn clone(&self) -> ChangeTracker
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ChangeTracker
impl Debug for ChangeTracker
Source§impl Default for ChangeTracker
impl Default for ChangeTracker
Source§fn default() -> ChangeTracker
fn default() -> ChangeTracker
Returns the “default value” for a type. Read more
Source§impl PartialEq for ChangeTracker
impl PartialEq for ChangeTracker
impl StructuralPartialEq for ChangeTracker
Auto Trait Implementations§
impl Freeze for ChangeTracker
impl RefUnwindSafe for ChangeTracker
impl Send for ChangeTracker
impl Sync for ChangeTracker
impl Unpin for ChangeTracker
impl UnsafeUnpin for ChangeTracker
impl UnwindSafe for ChangeTracker
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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 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>
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