pub struct ChangeTracker<T> { /* private fields */ }Expand description
Tracks changes to data. Notifies listeners via a futures::Stream.
The data to be tracked is type T. The value of type T is wrapped in a
private field. The AsRef trait is implemented so &T can be obtained by
calling as_ref(). Read and write access can be gained by calling the
modify method.
Subscribe to changes by calling get_changes.
Note that this does not implement Clone because typically this is not what
you want. Rather, you should wrap ChangeTracker in Arc<RwLock> or similar.
See the module-level documentation for more information and a usage example.
Implementations§
Source§impl<T> ChangeTracker<T>where
T: Clone,
impl<T> ChangeTracker<T>where
T: Clone,
Sourcepub fn new(value: T) -> Self
pub fn new(value: T) -> Self
Create a new ChangeTracker which takes ownership
of the data of type T.
Sourcepub fn get_changes(&self, capacity: usize) -> Receiver<(T, T)>
pub fn get_changes(&self, capacity: usize) -> Receiver<(T, T)>
Returns a futures::Stream that emits a message when a change occurs
The capacity of the underlying channel is specified with the capacity
argument.
To remove a listener, drop the Receiver.