[][src]Enum vgtk::UpdateAction

pub enum UpdateAction<C: Component> {
    None,
    Render,
    Defer(Pin<Box<dyn Future<Output = C::Message> + 'static>>),
}

An action resulting from a Component::update().

Variants

None

No action is necessary.

Use this when your update function didn't modify the component state in a way that alters the output of the view function.

Render

Re-render the widget tree.

Use this when you've modified the component state and the component should call its view function and re-render itself to reflect the new state.

Defer(Pin<Box<dyn Future<Output = C::Message> + 'static>>)

Run an async task and update again when it completes, passing the message returned from the Future to Component::update().

You should call UpdateAction::defer() or rely on the From<Future> implementation (see the example below) to construct this, rather than trying to box up your Future yourself.

Examples

enum Message {
    StartJob,
    JobDone,
}

fn update(&mut self, message: Self::Message) -> UpdateAction<Self> {
    match message {
        Message::StartJob => async {
            Message::JobDone
        }.into(),
        Message::JobDone => UpdateAction::Render,
    }
}

Implementations

impl<C: Component> UpdateAction<C>[src]

pub fn defer(job: impl Future<Output = C::Message> + 'static) -> Self[src]

Construct a deferred action given a Future.

Trait Implementations

impl<C, F> From<F> for UpdateAction<C> where
    C: Component,
    F: Future<Output = C::Message> + 'static, 
[src]

Auto Trait Implementations

impl<C> !RefUnwindSafe for UpdateAction<C>

impl<C> !Send for UpdateAction<C>

impl<C> !Sync for UpdateAction<C>

impl<C> Unpin for UpdateAction<C>

impl<C> !UnwindSafe for UpdateAction<C>

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