[−][src]Struct async_change_tracker::ChangeTracker
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.
Subsribe to changes by calling get_changes
.
See the module-level documentation for more information and a usage example.
Methods
impl<T> ChangeTracker<T> where
T: Clone,
[src]
T: Clone,
pub fn new(value: T) -> Self
[src]
Create a new ChangeTracker
which takes ownership
of the data of type T
.
pub fn get_changes(&self, capacity: usize) -> Receiver<(T, T)>
[src]
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.
pub fn modify<F>(&mut self, f: F) where
F: FnOnce(&mut T),
[src]
F: FnOnce(&mut T),
Modify the data value, notifying listeners upon change.
Trait Implementations
Auto Trait Implementations
impl<T> Send for ChangeTracker<T> where
T: Send,
T: Send,
impl<T> Sync for ChangeTracker<T> where
T: Send + Sync,
T: Send + Sync,
impl<T> Unpin for ChangeTracker<T> where
T: Unpin,
T: Unpin,
impl<T> !UnwindSafe for ChangeTracker<T>
impl<T> !RefUnwindSafe for ChangeTracker<T>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,