Skip to main content

qubit_retry/
lib.rs

1/*******************************************************************************
2 *
3 *    Copyright (c) 2025 - 2026.
4 *    Haixing Hu, Qubit Co. Ltd.
5 *
6 *    All rights reserved.
7 *
8 ******************************************************************************/
9//! Type-preserving retry executors for synchronous and asynchronous operations.
10//!
11//! `RetryExecutor<E>` binds only the operation error type. The success type `T`
12//! is introduced on `run` / `run_async`, so normal error retry does not require
13//! `T: Clone + Eq + Hash`.
14//!
15//! The default error type is `BoxError` from the `qubit-common` crate. It is not
16//! re-exported by this crate; callers that need the boxed error alias should
17//! import it from `qubit-common` directly.
18
19pub mod error;
20pub mod event;
21pub mod options;
22
23mod retry_executor;
24mod retry_executor_builder;
25
26pub use error::{RetryAttemptFailure, RetryConfigError, RetryError, RetryErrorClassifier};
27pub use event::{
28    RetryAbortContext, RetryAbortListener, RetryAttemptContext, RetryContext, RetryDecision,
29    RetryFailureContext, RetryFailureListener, RetryListener, RetrySuccessContext,
30    RetrySuccessListener,
31};
32pub use options::{RetryDelay, RetryJitter, RetryOptions};
33pub use retry_executor::RetryExecutor;
34pub use retry_executor_builder::RetryExecutorBuilder;
35
36/// Result alias returned by retry executor execution.
37///
38/// The success type `T` is chosen by each operation. The error type `E`
39/// remains the caller's original application error and is wrapped by
40/// [`RetryError`] only when retry execution terminates unsuccessfully.
41pub type RetryResult<T, E> = Result<T, RetryError<E>>;