pub trait Computable<T> {
// Required method
fn try_compute(&mut self) -> Completable<T>;
// Provided methods
fn compute_completable(&mut self) -> Completable<T> { ... }
fn compute(&mut self) -> Cancellable<T> { ... }
fn dyn_computable(self) -> DynComputable<T>
where Self: Sized + 'static { ... }
}Expand description
A generic trait implemented by types that represent a “computation”.
To advance the computation, repeatedly call Computable::try_compute until a value is
returned. Once the value is returned, the computable becomes “exhausted” and will return
Incomplete::Exhausted.
See also ComputableResult and crate::Computation.
Required Methods§
Sourcefn try_compute(&mut self) -> Completable<T>
fn try_compute(&mut self) -> Completable<T>
Try to advance this computation, returning a value once the computation is done.
Provided Methods§
Sourcefn compute_completable(&mut self) -> Completable<T>
fn compute_completable(&mut self) -> Completable<T>
Advance this computation until it either completes, is canceled, or becomes exhausted, skipping over all suspended states.
This method is identical to repeatedly calling Computable::try_compute until it
returns something other than Incomplete::Suspended.
Note that this method can loop forever if the computation never completes and keeps
returning Incomplete::Suspended.
Sourcefn compute(&mut self) -> Cancellable<T>
fn compute(&mut self) -> Cancellable<T>
Advance this computation until completion, skipping over all suspended states.
§Panics
Panics if called on an exhausted computation, i.e., if Computable::try_compute returns
Incomplete::Exhausted. If you want to handle exhaustion gracefully, use
Computable::compute_completable instead.
Sourcefn dyn_computable(self) -> DynComputable<T>where
Self: Sized + 'static,
fn dyn_computable(self) -> DynComputable<T>where
Self: Sized + 'static,
Utility method to convert this Computable to a dynamic type.