raii_change_tracker

Struct DataTracker

Source
pub struct DataTracker<T>
where T: Clone + PartialEq,
{ /* 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>
where T: Clone + PartialEq,

Source

pub fn new(value: T) -> DataTracker<T>

Create a new DataTracker which takes ownership of the data of type T.

Source

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.

Source

pub fn as_tracked_mut(&mut self) -> Modifier<'_, T>

Return a Modifier which can be used to modify the owned data.

Trait Implementations§

Source§

impl<T> AsRef<T> for DataTracker<T>
where T: Clone + PartialEq,

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.

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>
where T: Sync + Send,

§

impl<T> Unpin for DataTracker<T>
where T: Unpin,

§

impl<T> !UnwindSafe for DataTracker<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.