pub enum AsyncValue<T> {
Idle,
Loading(Option<T>),
Ready(T),
Error(Arc<dyn Error + Sync + Send>),
}Expand description
The heavy-work idiom: AsyncValue state,
use_task (the blessed load/compute helper), UseTask handle, and
spawn_blocking (the CPU-bound entry point) — Frust’s counterpart to
Flutter’s compute()/FutureBuilder, with explicit cancellation on
component teardown. spawn_blocking joins the existing
spawn/spawn_local routing pair (async IO / UI-thread !Send /
one-off CPU work). App crates need no new dependency: this is the whole
heavy-work surface. See frust_reactive::task for the threading contract.
The exhaustive state of an asynchronously-loaded value.
Deliberately named for parity with Riverpod’s AsyncValue<T> (Flutter) —
the genuine prior art for a load/data/error sum type with exhaustive
matching (research §9). The four states are:
Idle— nothing requested yet.Loading— a fetch is in flight. It carries the previous value (Someon a refresh,Noneon a first load), so a UI can keep showing stale data instead of flickering to a spinner — mirroring Riverpod’scopyWithPrevious.Ready— the fetch resolved to a value.Error— the fetch failed.
Variants§
Idle
No fetch requested yet.
Loading(Option<T>)
A fetch is in flight; carries the previous value for
refresh-without-flicker (None on a first load).
Ready(T)
The fetch resolved.
Error(Arc<dyn Error + Sync + Send>)
The fetch failed.
Implementations§
Source§impl<T> AsyncValue<T>
impl<T> AsyncValue<T>
Trait Implementations§
Source§impl<T> Clone for AsyncValue<T>where
T: Clone,
impl<T> Clone for AsyncValue<T>where
T: Clone,
Source§fn clone(&self) -> AsyncValue<T>
fn clone(&self) -> AsyncValue<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T> Debug for AsyncValue<T>where
T: Debug,
impl<T> Debug for AsyncValue<T>where
T: Debug,
Source§impl<T> Default for AsyncValue<T>
impl<T> Default for AsyncValue<T>
Source§fn default() -> AsyncValue<T>
fn default() -> AsyncValue<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for AsyncValue<T>
impl<T> !UnwindSafe for AsyncValue<T>
impl<T> Freeze for AsyncValue<T>
impl<T> Send for AsyncValue<T>
impl<T> Sync for AsyncValue<T>
impl<T> Unpin for AsyncValue<T>
impl<T> UnsafeUnpin for AsyncValue<T>
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.