[][src]Struct valerie::state::StateMutex

pub struct StateMutex<T> { /* fields omitted */ }

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]

pub fn from<U, F>(state: &U, func: F) -> Self where
    U: StateTrait + 'static,
    F: FnMut(U::Value) -> Self::Value + 'static, 
[src]

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]

type Output = Self

The resulting type after applying the + operator.

impl<T, U> AddAssign<U> for StateMutex<T> where
    T: Display + Clone + AddAssign<U>, 
[src]

impl<T> Clone for StateMutex<T>[src]

impl<T> Component for StateMutex<T> where
    T: Display + Clone
[src]

impl<T, U> Div<U> for StateMutex<T> where
    T: Display + Clone + Div<U> + DivAssign<U>, 
[src]

type Output = Self

The resulting type after applying the / operator.

impl<T, U> DivAssign<U> for StateMutex<T> where
    T: Display + Clone + DivAssign<U>, 
[src]

impl<T> Eq for StateMutex<T>[src]

impl<T> From<StateMutex<T>> for Node where
    T: Display + Clone
[src]

impl<T, U> Mul<U> for StateMutex<T> where
    T: Display + Clone + Mul<U> + MulAssign<U>, 
[src]

type Output = Self

The resulting type after applying the * operator.

impl<T, U> MulAssign<U> for StateMutex<T> where
    T: Display + Clone + MulAssign<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]

type Output = Self

The resulting type after applying the % operator.

impl<T, U> RemAssign<U> for StateMutex<T> where
    T: Display + Clone + RemAssign<U>, 
[src]

impl<T> StateTrait for StateMutex<T> where
    T: Display + Clone
[src]

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.

impl<T, U> Sub<U> for StateMutex<T> where
    T: Display + Clone + Sub<U> + SubAssign<U>, 
[src]

type Output = Self

The resulting type after applying the - operator.

impl<T, U> SubAssign<U> for StateMutex<T> where
    T: Display + Clone + SubAssign<U>, 
[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for StateMutex<T>

impl<T> Send for StateMutex<T> where
    T: Send

impl<T> Sync for StateMutex<T> where
    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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.