[][src]Struct moxie::embed::Runtime

pub struct Runtime<Root> { /* 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));
}

Methods

impl<Root, Out> Runtime<Root> where
    Root: FnMut() -> Out, 
[src]

pub fn new(root: Root) -> Self[src]

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

By default the task executor used for load and its siblings is the same single-threaded one as the executor used for handler futures. It is strongly recommended that outside of testing users of this struct call set_task_executor with a reference to a more robust I/O- or compute-oriented executor.

pub fn oneshot(root: Root) -> Out[src]

Constructs a new Runtime, runs the provided root once, and returns the result.

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(&mut self) -> Out[src]

Runs the root closure once with access to memoization storage, increments the runtime's Revision, and drops any memoized values which were not marked Liveness::Live.

pub fn run_until_ready(&mut self, filter: impl FnMut(Out) -> Poll<Out>) -> Out[src]

Calls run_once in a loop until filter returns Poll::Ready, returning the result of that Revision.

pub fn run_until_at_least_revision(&mut self, rev: Revision) -> Out[src]

Calls run_once in a loop until the runtime's revision is equal to the one provided.

Always calls run_once at least once.

pub fn set_state_change_waker(&mut self, wk: Waker) -> &mut Self[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) -> &mut Self[src]

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

Auto Trait Implementations

impl<Root> !RefUnwindSafe for Runtime<Root>

impl<Root> !Send for Runtime<Root>

impl<Root> !Sync for Runtime<Root>

impl<Root> Unpin for Runtime<Root> where
    Root: Unpin

impl<Root> !UnwindSafe for Runtime<Root>

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> 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.