pub struct AsyncView<'a, T, E> { /* private fields */ }Expand description
A standardized widget that exhaustively handles the Idle, Pending,
Failed, and Finished states of a data fetch.
Use this to wrap the core visual components of your app that rely on external data.
Implementations§
Source§impl<'a, T, E> AsyncView<'a, T, E>
impl<'a, T, E> AsyncView<'a, T, E>
Sourcepub fn loading_text(self, text: impl Into<String>) -> Self
pub fn loading_text(self, text: impl Into<String>) -> Self
Sets the text to display below the spinner when the fetch is pending.
Sourcepub fn error_retry_text(self, text: impl Into<String>) -> Self
pub fn error_retry_text(self, text: impl Into<String>) -> Self
Sets the text to display on the retry button when the fetch fails.
Sourcepub const fn state_layout(self, layout: StateLayout) -> Self
pub const fn state_layout(self, layout: StateLayout) -> Self
Configures the layout strategy for the intermediate loading and error states.
Sourcepub fn show<Fut, R>(
self,
ui: &mut Ui,
fetch: impl FnOnce() -> Fut,
on_ok: impl FnOnce(&mut Ui, &T) -> R,
) -> Option<R>
pub fn show<Fut, R>( self, ui: &mut Ui, fetch: impl FnOnce() -> Fut, on_ok: impl FnOnce(&mut Ui, &T) -> R, ) -> Option<R>
Runs the state machine. If data is successfully loaded, it invokes on_ok
to let you render your successful data.
§Returns
Some(R) if the data is available and successfully rendered, otherwise None.
Auto Trait Implementations§
impl<'a, T, E> Freeze for AsyncView<'a, T, E>
impl<'a, T, E> !RefUnwindSafe for AsyncView<'a, T, E>
impl<'a, T, E> Send for AsyncView<'a, T, E>
impl<'a, T, E> Sync for AsyncView<'a, T, E>
impl<'a, T, E> Unpin for AsyncView<'a, T, E>
impl<'a, T, E> UnsafeUnpin for AsyncView<'a, T, E>
impl<'a, T, E> !UnwindSafe for AsyncView<'a, T, E>
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