# Struct client::RetryPolicy

> Exponential backoff: `initial_ms`, then ×`factor`, capped at `cap_ms`; give up once `give_up_ms` have passed since the first send.

`zaun_community_protocol::client::RetryPolicy` · Struct

```rust
pub struct RetryPolicy { … }
```

Exponential backoff: `initial_ms`, then ×`factor`, capped at `cap_ms`; give up once
`give_up_ms` have passed since the first send.

A resend also waits until the host has been silent for `initial_ms` (at most `cap_ms`
longer): while its messages are still arriving, the answer is most likely among them.

## Fields

### `initial_ms: u64`

Delay before the first retry.

### `factor: u64`

Multiplier per attempt.

### `cap_ms: u64`

Largest delay.

### `give_up_ms: u64`

Total time after which a request is abandoned.

## Methods

### `delay`

```rust
pub fn delay(&self, attempt: u32) -> u64
```

The delay after send number `attempt` (1 = the first send): 5 s, 10 s, 20 s, 40 s,
then 60 s.

### `refused_delay`

```rust
pub fn refused_delay(&self, attempt: u32) -> u64
```

The delay after a transient error on send number `attempt`: 2 s, 4 s, 8 s, … 60 s,
never longer than `RetryPolicy::delay`.

### `next_at`

```rust
pub fn next_at(&self, now_ms: u64, attempt: u32, error: Option<&ErrorBody>) -> u64
```

The next send time after send number `attempt` at `now_ms`: the backoff, or after a
transient `error` its `RetryPolicy::refused_delay` or, if later, its
`retry_after_ms`.

### `resend_now`

```rust
pub const fn resend_now(&self, due_ms: u64, heard_ms: Option<u64>, now_ms: u64) -> bool
```

Whether a resend due at `due_ms` goes out at `now_ms`, the host last heard at
`heard_ms`: once the host has been silent for `initial_ms`, or `cap_ms` after it was
due, whatever the host is sending.

### `expired`

```rust
pub const fn expired(&self, first_ms: u64, now_ms: u64) -> bool
```

Whether a request first sent at `first_ms` is abandoned at `now_ms`.

## Trait implementations

`Clone`, `Copy`, `Debug`, `Default`, `Eq`, `PartialEq`, `StructuralPartialEq`

[Full rustdoc page](/docs/api/rust/zaun-community-protocol/zaun_community_protocol/client/retry/struct.RetryPolicy.html)
