pub struct NetworkRetry {
pub reconnect_interval: u16,
pub maximum_retries: u32,
/* private fields */
}Available on crate feature
network-client and non-WebAssembly only.Expand description
Network retry state and logic for exponential backoff.
Fields§
§reconnect_interval: u16Reconnect interval.
maximum_retries: u32Maximum number of retries.
Implementations§
Source§impl NetworkRetry
impl NetworkRetry
Sourcepub fn new(maximum_retries: u32, reconnect_interval: u16) -> Self
pub fn new(maximum_retries: u32, reconnect_interval: u16) -> Self
Create a new network retry.
The reconnect interval is a base interval in milliseconds
for the exponential backoff so use a small value such as
1000 or 2000.
Sourcepub fn delay(&self, retries: u32) -> Result<u64, Error>
pub fn delay(&self, retries: u32) -> Result<u64, Error>
Exponential backoff millisecond delay for a retry counter.
Sourcepub fn clone_reset(&self) -> Self
pub fn clone_reset(&self) -> Self
Clone of this network retry with the retry counter reset.
Sourcepub fn is_exhausted(&self, retries: u32) -> bool
pub fn is_exhausted(&self, retries: u32) -> bool
Determine if retry attempts are exhausted.
Sourcepub async fn wait_and_retry<D, T, F>(
&self,
id: D,
retries: u32,
callback: F,
cancel: Receiver<CancelReason>,
) -> Result<T, Error>
pub async fn wait_and_retry<D, T, F>( &self, id: D, retries: u32, callback: F, cancel: Receiver<CancelReason>, ) -> Result<T, Error>
Wait and then retry.
Trait Implementations§
Source§impl Clone for NetworkRetry
impl Clone for NetworkRetry
Source§fn clone(&self) -> NetworkRetry
fn clone(&self) -> NetworkRetry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NetworkRetry
impl Debug for NetworkRetry
Auto Trait Implementations§
impl Freeze for NetworkRetry
impl RefUnwindSafe for NetworkRetry
impl Send for NetworkRetry
impl Sync for NetworkRetry
impl Unpin for NetworkRetry
impl UnwindSafe for NetworkRetry
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