[−][src]Struct drying_paint::WatchContext
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:
- Calling WatchContext::update_current() (you can use WatchContext::update() to concisely update a context from outside itself).
- Mutating a Watched value.
- Calling WatchedEvent::dispatch()
- Calling WatchedMeta::trigger() (the two above are actually just specific variations on this)
- Creating a Watcher
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
impl !Send for WatchContext
impl !Sync for WatchContext
impl Unpin for WatchContext
impl !UnwindSafe for WatchContext
impl !RefUnwindSafe for WatchContext
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,