Skip to main content

qubit_http/error/
retry_hint.rs

1/*******************************************************************************
2 *
3 *    Copyright (c) 2025 - 2026 Haixing Hu.
4 *
5 *    SPDX-License-Identifier: Apache-2.0
6 *
7 *    Licensed under the Apache License, Version 2.0.
8 *
9 ******************************************************************************/
10//! # Retry Hint
11//!
12//! Provides lightweight retryability classification for HTTP errors.
13//!
14
15use parse_display::{
16    Display,
17    FromStr as DeriveFromStr,
18};
19use serde::{
20    Deserialize,
21    Serialize,
22};
23
24/// High-level classification from [`crate::HttpError::retry_hint`] for backoff policies.
25#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Display, DeriveFromStr)]
26#[serde(rename_all = "snake_case")]
27#[display(style = "snake_case")]
28pub enum RetryHint {
29    /// Transient failure (timeouts, some 5xx/429, transport); callers may retry with care.
30    Retryable,
31    /// Permanent or non-idempotent failure; do not retry by default.
32    NonRetryable,
33}