Struct backon::ConstantBuilder
source · pub struct ConstantBuilder { /* private fields */ }
Expand description
ConstantBuilder is used to build ConstantBackoff
§Default
- delay: 1s
- max times: 3
§Examples
use anyhow::Result;
use backon::ConstantBuilder;
use backon::Retryable;
async fn fetch() -> Result<String> {
Ok(reqwest::get("https://www.rust-lang.org")
.await?
.text()
.await?)
}
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
let content = fetch.retry(&ConstantBuilder::default()).await?;
println!("fetch succeeded: {}", content);
Ok(())
}
Implementations§
source§impl ConstantBuilder
impl ConstantBuilder
sourcepub fn with_delay(self, delay: Duration) -> Self
pub fn with_delay(self, delay: Duration) -> Self
Set delay of current backoff.
sourcepub fn with_max_times(self, max_times: usize) -> Self
pub fn with_max_times(self, max_times: usize) -> Self
Set max times of current backoff.
sourcepub fn with_jitter(self) -> Self
pub fn with_jitter(self) -> Self
Set jitter on
Trait Implementations§
source§impl BackoffBuilder for ConstantBuilder
impl BackoffBuilder for ConstantBuilder
source§impl Clone for ConstantBuilder
impl Clone for ConstantBuilder
source§fn clone(&self) -> ConstantBuilder
fn clone(&self) -> ConstantBuilder
Returns a copy 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 ConstantBuilder
impl Debug for ConstantBuilder
Auto Trait Implementations§
impl Freeze for ConstantBuilder
impl RefUnwindSafe for ConstantBuilder
impl Send for ConstantBuilder
impl Sync for ConstantBuilder
impl Unpin for ConstantBuilder
impl UnwindSafe for ConstantBuilder
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