pub struct Notify<T> { /* private fields */ }Expand description
A lightweight wrapper that guarantees an event will be generated every time the inner value is accessed mutably, even if the value doesn’t change.
This is useful for types like a play head where periodically writing the same value carries useful information.
Notify implements core::ops::Deref and core::ops::DerefMut
for the inner T.
Implementations§
Source§impl<T> Notify<T>
impl<T> Notify<T>
Sourcepub fn new(value: T) -> Self
pub fn new(value: T) -> Self
Construct a new Notify.
If two instances of Notify are constructed separately,
a call to Diff::diff will produce an event, even if the
value is the same.
// Diffing `a` and `b` will produce an event
let a = Notify::new(1);
let b = Notify::new(1);
// whereas `b` and `c` will not.
let c = b.clone();Sourcepub fn as_mut_unsync(&mut self) -> &mut T
pub fn as_mut_unsync(&mut self) -> &mut T
Get mutable access to the inner value without updating the ID.
Trait Implementations§
Source§impl<T: Clone + Send + Sync + 'static> Diff for Notify<T>
impl<T: Clone + Send + Sync + 'static> Diff for Notify<T>
Source§fn diff<E: EventQueue>(
&self,
baseline: &Self,
path: PathBuilder,
event_queue: &mut E,
)
fn diff<E: EventQueue>( &self, baseline: &Self, path: PathBuilder, event_queue: &mut E, )
Compare
self to baseline and generate events to resolve any differences.Source§impl<T: Clone + Send + Sync + 'static> Patch for Notify<T>
impl<T: Clone + Send + Sync + 'static> Patch for Notify<T>
Auto Trait Implementations§
impl<T> Freeze for Notify<T>where
T: Freeze,
impl<T> RefUnwindSafe for Notify<T>where
T: RefUnwindSafe,
impl<T> Send for Notify<T>where
T: Send,
impl<T> Sync for Notify<T>where
T: Sync,
impl<T> Unpin for Notify<T>where
T: Unpin,
impl<T> UnwindSafe for Notify<T>where
T: UnwindSafe,
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().