[][src]Trait reax::Variable

pub trait Variable: Sized {
    type Value;
    fn node(&self) -> &Node;
fn get(&self) -> Ref<Self::Value>;
fn get_non_reactive(&self) -> Ref<Self::Value>; fn get_copy(&self) -> Self::Value
    where
        Self::Value: Copy
, { ... }
fn map<T, F>(self, func: F) -> ComputedVar<FunctionMapped<Self, T, F>>
    where
        F: FnMut(&Self::Value) -> T
, { ... }
fn map_mutate<T, F>(
        self,
        initial: T,
        func: F
    ) -> ComputedVar<MutatorMapped<Self, T, F>>
    where
        F: FnMut(&Self::Value, &mut T)
, { ... }
fn with_label(self, label: impl Display) -> Self { ... } }

A trait implemented by any wrapped data which reax can manage.

Associated Types

type Value

The type of this variable.

Loading content...

Required methods

fn node(&self) -> &Node

Returns a handle to this variable's node in the reax runtime's dependency graph.

fn get(&self) -> Ref<Self::Value>

Returns the value of this variable.

Note that right now this trait assumes that the data is stored behind a RefCell. The source of interior mutability can be made more generic once GATs are stabilized.

fn get_non_reactive(&self) -> Ref<Self::Value>

Returns the value of this variable without alerting the reax runtime that the variable is used in the current context. See also get.

Loading content...

Provided methods

fn get_copy(&self) -> Self::Value where
    Self::Value: Copy

Returns the value of this variable by copy where possible. See also get.

fn map<T, F>(self, func: F) -> ComputedVar<FunctionMapped<Self, T, F>> where
    F: FnMut(&Self::Value) -> T, 

Create a new ComputedVar which depends only on this variable. The value of the returned cell is lazily computed by the given function. That is, the function will not be executed until someone retrieves the value of the cell. This can be used similarly to EagerCompute::watch if the resulting cell is checked frequently. See also ComputedVar::new.

Note that variables should usually be borrowed or Rc::cloneed before being passed to this function (e.g. (&variable).map(...)).

fn map_mutate<T, F>(
    self,
    initial: T,
    func: F
) -> ComputedVar<MutatorMapped<Self, T, F>> where
    F: FnMut(&Self::Value, &mut T), 

Create a new ComputedVar which depends only on this variable. The value of the returned cell is lazily updated by the given function. That is, the function will not be executed until someone retrieves the value of the cell. This can be used similarly to EagerCompute::watch if the resulting cell is checked frequently. See also ComputedVar::new_mutate.

Note that variables should usually be borrowed or Rc::cloneed before being passed to this function (e.g. (&variable).map_mutate(...)).

fn with_label(self, label: impl Display) -> Self

Provides the runtime with a variable name to use in debug outputs. This does nothing in release builds.

Loading content...

Implementations on Foreign Types

impl<'r, T> Variable for &'r T where
    T: Variable
[src]

type Value = T::Value

impl<T> Variable for Rc<T> where
    T: Variable
[src]

type Value = T::Value

impl<T> Variable for Box<T> where
    T: Variable
[src]

type Value = T::Value

Loading content...

Implementors

impl<C: ComputedValue<Context = ()>> Variable for ComputedVar<C>[src]

type Value = C::Value

impl<T> Variable for Var<T>[src]

type Value = T

Loading content...