Struct eyeball::ObservableWriteGuard
source · pub struct ObservableWriteGuard<'a, T: 'a, L: Lock = SyncLock> { /* private fields */ }
Expand description
A write guard for the inner value of an observable.
Note that as long as an ObservableWriteGuard
is kept alive, the associated
SharedObservable
is locked and can not be updated except through that
guard.
Implementations§
source§impl<'a, T: 'a, L: Lock> ObservableWriteGuard<'a, T, L>
impl<'a, T: 'a, L: Lock> ObservableWriteGuard<'a, T, L>
sourcepub fn set(this: &mut Self, value: T) -> T
pub fn set(this: &mut Self, value: T) -> T
Set the inner value to the given value
, notify subscribers and return
the previous value.
sourcepub fn set_if_not_eq(this: &mut Self, value: T) -> Option<T>where
T: PartialEq,
pub fn set_if_not_eq(this: &mut Self, value: T) -> Option<T>where
T: PartialEq,
Set the inner value to the given value
if it doesn’t compare equal to
the existing value.
If the inner value is set, subscribers are notified and
Some(previous_value)
is returned. Otherwise, None
is returned.
sourcepub fn set_if_hash_not_eq(this: &mut Self, value: T) -> Option<T>where
T: Hash,
pub fn set_if_hash_not_eq(this: &mut Self, value: T) -> Option<T>where
T: Hash,
Set the inner value to the given value
if it has a different hash than
the existing value.
If the inner value is set, subscribers are notified and
Some(previous_value)
is returned. Otherwise, None
is returned.
sourcepub fn take(this: &mut Self) -> Twhere
T: Default,
pub fn take(this: &mut Self) -> Twhere
T: Default,
Set the inner value to a Default
instance of its type, notify
subscribers and return the previous value.
Shorthand for ObservableWriteGuard::set(this, T::default())
.