[][src]Struct drying_paint::WatchContext

pub struct WatchContext { /* fields omitted */ }

Most of the functions in this crate require that they are executing in a context. The context keeps track of some "global" state which enables the functionality in this crate.

The following will panic if done outside of a WatchContext:

When a watched value changes, the code watching those values will be queued onto the WatchContext. WatchContext::update_current() will execute all pending operations. Note: Because Watcher makes use of a RefCell internally to execute the watching code, you should not keep references gotten from Watcher::data() or Watcher::data_mut() around during WatchContext::update_current() or WatchContext::update().

Methods

impl WatchContext[src]

pub fn new() -> Self[src]

Create a new WatchContext

pub fn with<F: FnOnce()>(&mut self, func: F)[src]

Set this WatchContext as the current one for the duration of the passed function. Note that it is supported (although discouraged) to nest WatchContexts within each other.

pub fn update_current()[src]

Execute all operations which are currently pending because a value they were watching changed. Note: Because Watcher makes use of a RefCell internally to execute the watching code, you should not keep references gotten from Watcher::data() or Watcher::data_mut() around during WatchContext::update_current() or WatchContext::update().

Panics

This function will panic if called outside of WatchContext::with, or if any function queued for update panics.

pub fn update(&mut self)[src]

The same as doing context.with(|| WatchContext::update_current())

Auto Trait Implementations

Blanket Implementations

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

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

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

type Error = !

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.

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

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]