pub struct Promise<A> {
pub has_result: bool,
pub success: Signal1<A>,
pub error: Signal1<String>,
pub progress_changed: Signal0,
pub result: Option<A>,
pub progress: f32,
pub total: f32,
}
Expand description
Represents a value that isn’t ready yet, but may become available in the future.
Fields
has_result: bool
Whether the result is available yet.
success: Signal1<A>
Emitted when the promise is fulfilled and the result has become available.
error: Signal1<String>
An error message emitted if there was a problem during loading.
progress_changed: Signal0
May be emitted during loading when the progress or total counts have been updated.
result: Option<A>
The end result fulfilled by the promise. When accessing, throws an error if the result is not yet available. Read hasResult to check availability first, or use get(). When setting, throws an error if the result was already previously assigned.
progress: f32
Context on how close this promise is to being fulfilled. For file IO, these are in bytes.
total: f32
Implementations
sourceimpl<A> Promise<A>
impl<A> Promise<A>
pub fn new() -> Promise<A>
pub fn result(&self) -> &Option<A>
pub fn set_result(&self, result: Option<A>) -> Option<A>
sourcepub fn get(
&self,
function: Box<dyn Fn(&A) + 'static, Global>
) -> Option<impl Disposable>
pub fn get(
&self,
function: Box<dyn Fn(&A) + 'static, Global>
) -> Option<impl Disposable>
Passes the result to the callback now if the result is available, otherwise calls it later. @returns If the callback was not called yet, a handle that can be disposed to cancel the request.
pub fn progress(&self) -> f32
pub fn set_progress(&mut self, progress: f32)
pub fn set_total(&mut self, total: f32)
pub fn total(&self) -> f32
Trait Implementations
Auto Trait Implementations
impl<A> !RefUnwindSafe for Promise<A>
impl<A> !Send for Promise<A>
impl<A> !Sync for Promise<A>
impl<A> Unpin for Promise<A> where
A: Unpin,
impl<A> !UnwindSafe for Promise<A>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<'a, T, C, M> Inspect<'a, C, &'a C, M> for T
impl<'a, T, C, M> Inspect<'a, C, &'a C, M> for T
impl<'a, T, C, M> Inspect<'a, C, &'a mut C, M> for T
impl<'a, T, C, M> Inspect<'a, C, &'a mut C, M> for T
impl<Fr, To> IntoColor<To> for Fr where
To: FromColor<Fr>,
impl<Fr, To> IntoColor<To> for Fr where
To: FromColor<Fr>,
fn into_color(self) -> To
fn into_color(self) -> To
Convert into color
impl<T> Pointable for T
impl<T> Pointable for T
impl<T> SetParameter for T
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
Sets value
as a parameter of self
.