Skip to main content

Atom

Struct Atom 

Source
pub struct Atom<V> { /* private fields */ }

Implementations§

Source§

impl<V> Atom<V>

Source

pub fn new(value: V) -> Self

Source

pub fn same_identity(&self, other: &Self) -> bool

Source

pub fn identity_address(&self) -> usize

Source

pub fn with_validator( value: V, validator: impl Fn(&V) -> bool + Send + Sync + 'static, ) -> Self

Source

pub fn add_watch( &self, key: impl Into<String>, watch: impl Fn(&WatchEntry<V>) + Send + Sync + 'static, )

Source

pub fn remove_watch(&self, key: &str)

Source§

impl<V: Clone> Atom<V>

Source

pub fn deref_value(&self) -> V

Source

pub fn reset(&self, new_value: V) -> Result<V, String>

Source

pub fn swap(&self, f: impl FnOnce(&V) -> V) -> Result<V, String>

Source§

impl<V: Clone + PartialEq> Atom<V>

Source

pub fn compare_and_set(&self, old: &V, new: V) -> Result<bool, String>

Trait Implementations§

Source§

impl<V: Clone> Clone for Atom<V>

Source§

fn clone(&self) -> Atom<V>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V> Debug for Atom<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: Display + Clone> Display for Atom<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: Clone> IDeref for Atom<V>

Source§

type Output = V

Source§

fn deref(&self) -> V

Source§

impl<V: Display + Clone> IDisplay for Atom<V>

Source§

fn display(&self) -> String

Source§

impl<V: Clone> IReset<V> for Atom<V>

Source§

type Error = String

Source§

fn reset(&self, value: V) -> Result<V, Self::Error>

Source§

impl<V: Clone> IWatch<V> for Atom<V>

Source§

type Key = String

Source§

type WatchEntry = WatchEntry<V>

Source§

fn add_watch( &self, key: Self::Key, watch: impl Fn(&Self::WatchEntry) + Send + Sync + 'static, )

Source§

fn remove_watch(&self, key: &Self::Key)

Source§

fn notify_watches(&self, old_value: V, new_value: V)

Source§

fn list_watches(&self) -> Vec<Self::WatchEntry>

Auto Trait Implementations§

§

impl<V> !RefUnwindSafe for Atom<V>

§

impl<V> !UnwindSafe for Atom<V>

§

impl<V> Freeze for Atom<V>
where Arc<Mutex<V>>: Freeze, Option<Arc<dyn Fn(&V) -> bool + Send + Sync>>: Freeze, Arc<Mutex<Vec<(String, Arc<dyn Fn(&WatchEntry<V>) + Send + Sync>)>>>: Freeze,

§

impl<V> Send for Atom<V>
where Arc<Mutex<V>>: Send, Option<Arc<dyn Fn(&V) -> bool + Send + Sync>>: Send, Arc<Mutex<Vec<(String, Arc<dyn Fn(&WatchEntry<V>) + Send + Sync>)>>>: Send,

§

impl<V> Sync for Atom<V>
where Arc<Mutex<V>>: Sync, Option<Arc<dyn Fn(&V) -> bool + Send + Sync>>: Sync, Arc<Mutex<Vec<(String, Arc<dyn Fn(&WatchEntry<V>) + Send + Sync>)>>>: Sync,

§

impl<V> Unpin for Atom<V>
where Arc<Mutex<V>>: Unpin, Option<Arc<dyn Fn(&V) -> bool + Send + Sync>>: Unpin, Arc<Mutex<Vec<(String, Arc<dyn Fn(&WatchEntry<V>) + Send + Sync>)>>>: Unpin,

§

impl<V> UnsafeUnpin for Atom<V>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more