aws_smithy_runtime/client/retries/strategy/
never.rs

1/*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6use aws_smithy_runtime_api::box_error::BoxError;
7use aws_smithy_runtime_api::client::interceptors::context::InterceptorContext;
8use aws_smithy_runtime_api::client::retries::{RetryStrategy, ShouldAttempt};
9use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
10use aws_smithy_types::config_bag::ConfigBag;
11
12/// A retry strategy that never retries.
13#[non_exhaustive]
14#[derive(Debug, Clone, Default)]
15pub struct NeverRetryStrategy;
16
17impl NeverRetryStrategy {
18    /// Creates a new `NeverRetryStrategy`.
19    pub fn new() -> Self {
20        Self::default()
21    }
22}
23
24impl RetryStrategy for NeverRetryStrategy {
25    fn should_attempt_initial_request(
26        &self,
27        _runtime_components: &RuntimeComponents,
28        _cfg: &ConfigBag,
29    ) -> Result<ShouldAttempt, BoxError> {
30        Ok(ShouldAttempt::Yes)
31    }
32
33    fn should_attempt_retry(
34        &self,
35        _context: &InterceptorContext,
36        _runtime_components: &RuntimeComponents,
37        _cfg: &ConfigBag,
38    ) -> Result<ShouldAttempt, BoxError> {
39        Ok(ShouldAttempt::No)
40    }
41}