pub struct DataTracker<T>{ /* private fields */ }
Expand description
Tracks changes to data and notifies listeners.
The data to be tracked is type T
.
Subsribe to changes by calling add_listener
.
See the module-level documentation for more details.
Implementations§
Source§impl<T> DataTracker<T>
impl<T> DataTracker<T>
Sourcepub fn new(value: T) -> DataTracker<T>
pub fn new(value: T) -> DataTracker<T>
Create a new DataTracker
which takes ownership
of the data of type T
.
Sourcepub fn add_listener(&mut self) -> Receiver<(T, T)>
pub fn add_listener(&mut self) -> Receiver<(T, T)>
Add a callback that will be called just after a data change is detected.
Returns a Receiver which will receive messages whenever a change occurs.
To remove a listener, drop the Receiver.
Sourcepub fn as_tracked_mut(&mut self) -> Modifier<'_, T>
pub fn as_tracked_mut(&mut self) -> Modifier<'_, T>
Return a Modifier
which can be used to modify the owned data.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for DataTracker<T>where
T: Freeze,
impl<T> !RefUnwindSafe for DataTracker<T>
impl<T> Send for DataTracker<T>where
T: Send,
impl<T> Sync for DataTracker<T>
impl<T> Unpin for DataTracker<T>where
T: Unpin,
impl<T> !UnwindSafe for DataTracker<T>
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