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: u8
Number 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) -> Instant
pub fn next_allowed_attempt(&self) -> Instant
The instant that needs to be waited for before another 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_get<F>(
&mut self,
ui: &mut Ui,
retry_msg: Option<&str>,
fetch_fn: F,
) -> CanMakeProgress
pub fn egui_get<F>( &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 get<F>(&mut self, fetch_fn: F) -> CanMakeProgress
pub fn get<F>(&mut self, fetch_fn: F) -> CanMakeProgress
Attempts to load the data and returns if it is able to make progress.
See DataState::get
for more info.
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
.
Trait Implementations§
Source§impl<T, E: ErrorBounds> AsMut<DataStateRetry<T, E>> for DataStateRetry<T, E>
impl<T, E: ErrorBounds> AsMut<DataStateRetry<T, E>> for DataStateRetry<T, E>
Source§fn as_mut(&mut self) -> &mut DataStateRetry<T, E>
fn as_mut(&mut self) -> &mut DataStateRetry<T, E>
Source§impl<T, E: ErrorBounds> AsRef<DataStateRetry<T, E>> for DataStateRetry<T, E>
impl<T, E: ErrorBounds> AsRef<DataStateRetry<T, E>> for DataStateRetry<T, E>
Source§fn as_ref(&self) -> &DataStateRetry<T, E>
fn as_ref(&self) -> &DataStateRetry<T, E>
Source§impl<T: Debug, E: Debug + ErrorBounds> Debug for DataStateRetry<T, E>
impl<T: Debug, E: Debug + ErrorBounds> Debug for DataStateRetry<T, E>
Source§impl<T, E: ErrorBounds> Default for DataStateRetry<T, E>
impl<T, E: ErrorBounds> Default for DataStateRetry<T, E>
Auto Trait Implementations§
impl<T, E> Freeze for DataStateRetry<T, E>
impl<T, E = Error> !RefUnwindSafe for DataStateRetry<T, E>
impl<T, E> Send for DataStateRetry<T, E>where
T: Send,
impl<T, E> Sync for DataStateRetry<T, E>
impl<T, E> Unpin for DataStateRetry<T, E>
impl<T, E = Error> !UnwindSafe for DataStateRetry<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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more