use crate::compat::Duration;
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct RetryState {
pub attempt: u32,
pub elapsed: Option<Duration>,
}
impl RetryState {
#[must_use]
pub const fn new(attempt: u32, elapsed: Option<Duration>) -> Self {
Self { attempt, elapsed }
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy)]
pub struct AttemptState<'a, T, E> {
pub attempt: u32,
pub elapsed: Option<Duration>,
pub outcome: &'a Result<T, E>,
pub next_delay: Option<Duration>,
}
impl<'a, T, E> AttemptState<'a, T, E> {
#[must_use]
pub const fn new(
attempt: u32,
elapsed: Option<Duration>,
outcome: &'a Result<T, E>,
next_delay: Option<Duration>,
) -> Self {
Self {
attempt,
elapsed,
outcome,
next_delay,
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy)]
pub struct ExitState<'a, T, E> {
pub attempt: u32,
pub elapsed: Option<Duration>,
pub outcome: &'a Result<T, E>,
pub stop_reason: crate::stats::StopReason,
}
impl<'a, T, E> ExitState<'a, T, E> {
#[must_use]
pub const fn new(
attempt: u32,
elapsed: Option<Duration>,
outcome: &'a Result<T, E>,
stop_reason: crate::stats::StopReason,
) -> Self {
Self {
attempt,
elapsed,
outcome,
stop_reason,
}
}
}