pub struct UiTask<R>(/* private fields */);
Expand description
Implementations§
source§impl<R> UiTask<R>
impl<R> UiTask<R>
sourcepub fn new_raw<F>(
event_loop_waker: Waker,
task: impl IntoFuture<IntoFuture = F>,
) -> UiTask<R>
pub fn new_raw<F>( event_loop_waker: Waker, task: impl IntoFuture<IntoFuture = F>, ) -> UiTask<R>
New task with already build event-loop waker.
App crate provides an integrated UiTaskWidget::new
that creates the waker for widgets.
sourcepub fn update(&mut self) -> Option<&R>
pub fn update(&mut self) -> Option<&R>
Polls the future if needed, returns a reference to the result if the task is done.
This does not poll the future if the task is done.
§App Update
This method must be called only once per app update, if it is called more than once it will cause execution bugs,
futures like task::yield_now
will not work correctly, variables will have old values when a new one
is expected and any other number of hard to debug issues will crop-up.
In debug builds this is validated and an error message is logged if incorrect updates are detected.
sourcepub fn is_ready(&self) -> bool
pub fn is_ready(&self) -> bool
Returns true
if the task is done.
This does not poll the future.
sourcepub fn into_result(self) -> Result<R, UiTask<R>>
pub fn into_result(self) -> Result<R, UiTask<R>>
Returns the result if the task is completed.
This does not poll the future, you must call update
to poll until a result is available,
then call this method to take ownership of the result.
Trait Implementations§
Auto Trait Implementations§
impl<R> Freeze for UiTask<R>where
R: Freeze,
impl<R> !RefUnwindSafe for UiTask<R>
impl<R> Send for UiTask<R>where
R: Send,
impl<R> !Sync for UiTask<R>
impl<R> Unpin for UiTask<R>where
R: Unpin,
impl<R> !UnwindSafe for UiTask<R>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more