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
/*******************************************************************************
*
* Copyright (c) 2025 - 2026.
* Haixing Hu, Qubit Co. Ltd.
*
* All rights reserved.
*
******************************************************************************/
//! # Abort Reason
//!
//! Describes the specific reason why an operation should be aborted.
//!
//! # Author
//!
//! Haixing Hu
use Error as StdError;
/// Abort reason enum
///
/// Describes the specific reason why an operation should be aborted,
/// indicating situations where retrying should not continue.
///
/// # Characteristics
///
/// - `Error`: Needs abortion due to an unrecoverable error (e.g.,
/// permission error, resource does not exist)
/// - `Result`: The returned result indicates that retrying should
/// not continue (e.g., explicit rejection, invalid request)
///
/// # Generic Parameters
///
/// * `T` - The return value type of the operation
///
/// # Use Cases
///
/// Identifies situations in retry strategies where retrying should
/// not occur, avoiding ineffective retry attempts.
///
/// # Example
///
/// ```rust
/// use qubit_retry::event::abort_reason::AbortReason;
/// use std::io::{Error, ErrorKind};
///
/// // Abort due to unrecoverable error
/// let error = Error::new(
/// ErrorKind::PermissionDenied,
/// "Permission denied"
/// );
/// let abort_by_error = AbortReason::<String>::Error(
/// Box::new(error)
/// );
///
/// // Abort due to explicit rejection result
/// let invalid_result = String::from("INVALID_REQUEST");
/// let abort_by_result = AbortReason::Result(invalid_result);
/// ```
///
/// # Author
///
/// Haixing Hu