Struct moxie::runtime::RunLoop[][src]

pub struct RunLoop<Root> { /* fields omitted */ }

A Runtime that is bound with a particular root function.

If running in a context with an async executor, can be consumed as a [futures::Stream] of crate::runtime::Revisions in order to provide the super::Runtime with a std::task::Waker.


impl<Root, Out> RunLoop<Root> where
    Root: FnMut() -> Out + Unpin

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

Creates a new Runtime attached to the provided root function.

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

Returns the runtime’s current Revision.

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

Sets the std::task::Waker which will be called when state variables change.

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

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

pub fn run_once(&mut self) -> Out[src]

Run the root function once within this runtime’s context, returning the result.

pub async fn run_on_state_changes(self)[src]

Poll this runtime without exiting. Discards any value returned from the root function. The future yields in between revisions and is woken on state changes.

pub fn unloop(self) -> (Runtime, Root)[src]

Unbinds the runtime from its current root function, returning both.

Trait Implementations

impl<Root, Out> Stream for RunLoop<Root> where
    Root: FnMut() -> Out + Unpin

type Item = (Revision, Out)

Values yielded by the stream.

fn poll_next(
    self: Pin<&mut Self>,
    cx: &mut FutContext<'_>
) -> Poll<Option<Self::Item>>

This Stream implementation runs a single revision for each call to poll_next, always returning Poll::Ready(Some(...)).

Auto Trait Implementations

impl<Root> !RefUnwindSafe for RunLoop<Root>

impl<Root> !Send for RunLoop<Root>

impl<Root> !Sync for RunLoop<Root>

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

impl<Root> !UnwindSafe for RunLoop<Root>

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> Downcast for T where
    T: Any

impl<T> Erased for T

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

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> StreamExt for T where
    T: Stream + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.