pub struct DataStateRetry<T, E: ErrorBounds = Error> {
pub max_attempts: u8,
pub retry_delay_millis: Range<u16>,
/* private fields */
}Expand description
Automatically retries with a delay on failure until attempts are exhausted
Fields§
§max_attempts: u8Number of attempts that the retries get reset to
retry_delay_millis: Range<u16>The range of milliseconds to select a random value from to set the delay to retry
Implementations§
Source§impl<T, E: ErrorBounds> DataStateRetry<T, E>
impl<T, E: ErrorBounds> DataStateRetry<T, E>
Sourcepub fn new(max_attempts: u8, retry_delay_millis: Range<u16>) -> Self
pub fn new(max_attempts: u8, retry_delay_millis: Range<u16>) -> Self
Creates a new instance of DataStateRetry
Sourcepub fn attempts_left(&self) -> u8
pub fn attempts_left(&self) -> u8
The number times left to retry before stopping trying
Sourcepub fn next_allowed_attempt(&self) -> u128
pub fn next_allowed_attempt(&self) -> u128
The number of millis after the epoch that an attempt is allowed
Sourcepub fn into_inner(self) -> DataState<T, E>
pub fn into_inner(self) -> DataState<T, E>
Consumes self and returns the unwrapped inner
Sourcepub fn present(&self) -> Option<&T>
pub fn present(&self) -> Option<&T>
Provides access to the stored data if available (returns Some if
self.inner is Data::Present(_))
Sourcepub fn present_mut(&mut self) -> Option<&mut T>
pub fn present_mut(&mut self) -> Option<&mut T>
Provides mutable access to the stored data if available (returns Some if
self.inner is Data::Present(_))
Sourcepub fn egui_start_or_poll<F, R>(
&mut self,
ui: &mut Ui,
retry_msg: Option<&str>,
fetch_fn: F,
) -> CanMakeProgress
pub fn egui_start_or_poll<F, R>( &mut self, ui: &mut Ui, retry_msg: Option<&str>, fetch_fn: F, ) -> CanMakeProgress
Attempts to load the data and displays appropriate UI if applicable.
Note see [DataState::egui_get] for more info.
Sourcepub fn start_or_poll<F, R>(&mut self, fetch_fn: F) -> CanMakeProgress
pub fn start_or_poll<F, R>(&mut self, fetch_fn: F) -> CanMakeProgress
Attempts to load the data and returns if it is able to make progress.
Sourcepub fn reset_attempts(&mut self)
pub fn reset_attempts(&mut self)
Resets the attempts taken
Sourcepub fn is_present(&self) -> bool
pub fn is_present(&self) -> bool
Returns true if the internal data state is DataState::Present.
Sourcepub fn is_none(&self) -> bool
pub fn is_none(&self) -> bool
Returns true if the internal data state is DataState::None.