[][src]Struct moxie::runtime::Runtime

pub struct Runtime { /* fields omitted */ }

The primary integration point between moxie and an embedding environment. Owns the cache and state for a moxie application. Each instance is independent.

Minimal Example

This example has no side effects in its root closure, and doesn't have any state variables which might require mutation wakeups.

let mut rt = Runtime::new();
assert_eq!(rt.revision().0, 0);
for i in 1..10 {
    rt.run_once(|| ());
    assert_eq!(rt.revision(), Revision(i));
}

Implementations

impl Runtime[src]

pub fn looped<Root, Out>(self, root: Root) -> RunLoop<Root> where
    Root: FnMut() -> Out, 
[src]

Returns this runtime bound with a specific root function it will run in a loop.

impl Runtime[src]

pub fn new() -> Self[src]

Construct a new Runtime with blank storage and no external waker or task executor.

By default no state change waker or task executor is populated.

pub fn revision(&self) -> Revision[src]

The current revision of the runtime, or how many times run_once has been invoked.

pub fn run_once<Out>(&mut self, op: impl FnOnce() -> Out) -> Out[src]

Runs the root closure once with access to the runtime context, increments the runtime's Revision, and drops any cached values which were not marked alive.

pub fn set_state_change_waker(&mut self, wk: Waker)[src]

Sets the std::task::Waker which will be called when state variables receive commits. By default the runtime no-ops on a state change, which is probably the desired behavior if the embedding system will call Runtime::run_once on a regular interval regardless.

pub fn set_task_executor(&mut self, sp: impl LocalSpawn + 'static)[src]

Sets the executor that will be used to spawn normal priority tasks.

Trait Implementations

impl Default for Runtime[src]

Auto Trait Implementations

impl !RefUnwindSafe for Runtime

impl !Send for Runtime

impl !Sync for Runtime

impl Unpin for Runtime

impl !UnwindSafe for Runtime

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> Downcast for T where
    T: Any

impl<T> Erased for T

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

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

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.