pub enum AsyncValue<T> {
Idle,
Loading(Option<T>),
Ready(T),
Error(TaskError),
}Expand description
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(TaskError)
The fetch failed.
Implementations§
Source§impl<T> AsyncValue<T>
impl<T> AsyncValue<T>
Trait Implementations§
Source§impl<T: Clone> Clone for AsyncValue<T>
impl<T: Clone> Clone for AsyncValue<T>
Source§impl<T: Debug> Debug for AsyncValue<T>
impl<T: Debug> Debug for 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.