1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*******************************************************************************
*
* Copyright (c) 2025 - 2026.
* Haixing Hu, Qubit Co. Ltd.
*
* All rights reserved.
*
******************************************************************************/
//! # Retry Reason
//!
//! Describes the specific reason why an operation needs to be retried.
//!
//! # Author
//!
//! Haixing Hu
use Error as StdError;
/// Retry reason enum
///
/// Describes the specific reason why an operation needs to be
/// retried, either due to an error or because the returned result
/// does not meet expectations.
///
/// # Characteristics
///
/// - `Error`: Needs retry due to an error (e.g., network exception,
/// timeout)
/// - `Result`: Needs retry because the returned result does not meet
/// expectations (e.g., empty return value, incomplete data)
///
/// # Generic Parameters
///
/// * `T` - The return value type of the operation
///
/// # Use Cases
///
/// Distinguishes different failure reasons in retry strategies to
/// adopt different retry approaches.
///
/// # Example
///
/// ```rust
/// use qubit_retry::event::retry_reason::RetryReason;
/// use std::io::{Error, ErrorKind};
///
/// // Retry due to error
/// let error = Error::new(
/// ErrorKind::ConnectionRefused,
/// "Connection refused"
/// );
/// let retry_by_error = RetryReason::<String>::Error(
/// Box::new(error)
/// );
///
/// // Retry due to result
/// let empty_result = String::new();
/// let retry_by_result = RetryReason::Result(empty_result);
/// ```
///
/// # Author
///
/// Haixing Hu