[−][src]Struct valerie::state::StateMutex
State variable to be used with types that implement Clone
This uses Mutex
of parking_lot internally.
Implementations
impl<T> StateMutex<T>
[src]
pub fn new(value: T) -> Self
[src]
Make a new StateMutex
variable.
Examples
let state = StateMutex::new(String::from("Hello, World!")); h3!(state)
impl<T> StateMutex<T> where
T: Display + Clone + 'static,
[src]
T: Display + Clone + 'static,
pub fn from<U, F>(state: &U, func: F) -> Self where
U: StateTrait + 'static,
F: FnMut(U::Value) -> Self::Value + 'static,
[src]
U: StateTrait + 'static,
F: FnMut(U::Value) -> Self::Value + 'static,
Derive a StateAtomic
variable from another variable implementing StateTrait
.
Examples
let string = StateMutex::new(String::from("This is a test.")); let length = StateMutex::from(&string, |x| { let mut result = String::from("The length is "); result.push_str(&x.len().to_string()); result }); div!( h3!("String: ", string), h3!(length) )
Trait Implementations
impl<T, U> Add<U> for StateMutex<T> where
T: Display + Clone + Add<U> + AddAssign<U>,
[src]
T: Display + Clone + Add<U> + AddAssign<U>,
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: U) -> Self::Output
[src]
impl<T, U> AddAssign<U> for StateMutex<T> where
T: Display + Clone + AddAssign<U>,
[src]
T: Display + Clone + AddAssign<U>,
fn add_assign(&mut self, other: U)
[src]
impl<T> Clone for StateMutex<T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> Component for StateMutex<T> where
T: Display + Clone,
[src]
T: Display + Clone,
impl<T, U> Div<U> for StateMutex<T> where
T: Display + Clone + Div<U> + DivAssign<U>,
[src]
T: Display + Clone + Div<U> + DivAssign<U>,
type Output = Self
The resulting type after applying the /
operator.
fn div(self, other: U) -> Self::Output
[src]
impl<T, U> DivAssign<U> for StateMutex<T> where
T: Display + Clone + DivAssign<U>,
[src]
T: Display + Clone + DivAssign<U>,
fn div_assign(&mut self, other: U)
[src]
impl<T> Eq for StateMutex<T>
[src]
impl<T> From<StateMutex<T>> for Node where
T: Display + Clone,
[src]
T: Display + Clone,
fn from(x: StateMutex<T>) -> Self
[src]
impl<T, U> Mul<U> for StateMutex<T> where
T: Display + Clone + Mul<U> + MulAssign<U>,
[src]
T: Display + Clone + Mul<U> + MulAssign<U>,
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: U) -> Self::Output
[src]
impl<T, U> MulAssign<U> for StateMutex<T> where
T: Display + Clone + MulAssign<U>,
[src]
T: Display + Clone + MulAssign<U>,
fn mul_assign(&mut self, other: U)
[src]
impl<T> PartialEq<StateMutex<T>> for StateMutex<T>
[src]
impl<T, U> Rem<U> for StateMutex<T> where
T: Display + Clone + Rem<U> + RemAssign<U>,
[src]
T: Display + Clone + Rem<U> + RemAssign<U>,
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, other: U) -> Self::Output
[src]
impl<T, U> RemAssign<U> for StateMutex<T> where
T: Display + Clone + RemAssign<U>,
[src]
T: Display + Clone + RemAssign<U>,
fn rem_assign(&mut self, other: U)
[src]
impl<T> StateTrait for StateMutex<T> where
T: Display + Clone,
[src]
T: Display + Clone,
type Value = T
Type that is stored in the State variable.
type Store = Mutex<T>
Type that is wrapped in Arc
which stores the value.
type Channel = Channel
Channel type is used to pass the message between the Sender and the Receiver.
fn value(&self) -> Self::Value
[src]
fn tx(&self) -> StateSender<Self::Channel>
[src]
fn rx(&self) -> StateReceiver<Self::Channel>
[src]
fn put(&self, value: Self::Value)
[src]
fn pointer(&self) -> Arc<Self::Store>
[src]
fn update(&self)
[src]
impl<T, U> Sub<U> for StateMutex<T> where
T: Display + Clone + Sub<U> + SubAssign<U>,
[src]
T: Display + Clone + Sub<U> + SubAssign<U>,
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: U) -> Self::Output
[src]
impl<T, U> SubAssign<U> for StateMutex<T> where
T: Display + Clone + SubAssign<U>,
[src]
T: Display + Clone + SubAssign<U>,
fn sub_assign(&mut self, other: U)
[src]
impl<T> Value for StateMutex<T> where
T: Clone + Display,
[src]
T: Clone + Display,
Auto Trait Implementations
impl<T> !RefUnwindSafe for StateMutex<T>
impl<T> Send for StateMutex<T> where
T: Send,
T: Send,
impl<T> Sync for StateMutex<T> where
T: Send,
T: Send,
impl<T> Unpin for StateMutex<T>
impl<T> !UnwindSafe for StateMutex<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut 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>,