13 13 | #[derive(Copy, Clone, PartialEq)]
|
14 14 | pub struct BehaviorVersion {
|
15 15 | inner: Inner,
|
16 16 | }
|
17 17 |
|
18 18 | #[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq)]
|
19 19 | enum Inner {
|
20 20 | // IMPORTANT: Order matters here for the `Ord` derive. Newer versions go to the bottom.
|
21 21 | V2023_11_09,
|
22 22 | V2024_03_28,
|
23 + | V2025_01_17,
|
23 24 | }
|
24 25 |
|
25 26 | impl BehaviorVersion {
|
26 27 | /// This method will always return the latest major version.
|
27 28 | ///
|
28 29 | /// This is the recommend choice for customers who aren't reliant on extremely specific behavior
|
29 30 | /// characteristics. For example, if you are writing a CLI app, the latest behavior major
|
30 31 | /// version is probably the best setting for you.
|
31 32 | ///
|
32 33 | /// If, however, you're writing a service that is very latency sensitive, or that has written
|
33 34 | /// code to tune Rust SDK behaviors, consider pinning to a specific major version.
|
34 35 | ///
|
35 - | /// The latest version is currently [`BehaviorVersion::v2024_03_28`]
|
36 + | /// The latest version is currently [`BehaviorVersion::v2025_01_17`]
|
36 37 | pub fn latest() -> Self {
|
37 - | Self::v2024_03_28()
|
38 + | Self::v2025_01_17()
|
39 + | }
|
40 + |
|
41 + | /// Behavior version for January 17th, 2025
|
42 + | ///
|
43 + | /// This version updates the default HTTP client and TLS stack. SDKs shipped with
|
44 + | /// a pre 1.x version of hyper and rustls originally. This behavior version updates
|
45 + | /// the HTTP+TLS stack to maintained versions.
|
46 + | ///
|
47 + | /// <div class="warning">
|
48 + | /// NOTE: In a future release behavior versions prior to this will require enabling
|
49 + | /// feature flags manually to keep the legacy Hyper stack as the default. Specifically the
|
50 + | /// `aws-smithy-runtime/tls-rustls` feature flag combined with an older behavior version.
|
51 + | /// </div>
|
52 + | pub fn v2025_01_17() -> Self {
|
53 + | Self {
|
54 + | inner: Inner::V2025_01_17,
|
55 + | }
|
38 56 | }
|
39 57 |
|
40 58 | /// Behavior version for March 28th, 2024.
|
41 59 | ///
|
42 60 | /// This version enables stalled stream protection for uploads (request bodies) by default.
|
43 61 | ///
|
44 62 | /// When a new behavior major version is released, this method will be deprecated.
|
63 + | #[deprecated(
|
64 + | since = "1.8.0",
|
65 + | note = "Superseded by v2025_01_17, which updates the default HTTPS client stack."
|
66 + | )]
|
45 67 | pub fn v2024_03_28() -> Self {
|
46 68 | Self {
|
47 69 | inner: Inner::V2024_03_28,
|
48 70 | }
|
49 71 | }
|
50 72 |
|
51 73 | /// Behavior version for November 9th, 2023.
|
52 74 | #[deprecated(
|
53 75 | since = "1.4.0",
|
54 - | note = "Superceded by v2024_03_28, which enabled stalled stream protection for uploads (request bodies) by default."
|
76 + | note = "Superseded by v2024_03_28, which enabled stalled stream protection for uploads (request bodies) by default."
|
55 77 | )]
|
56 78 | pub fn v2023_11_09() -> Self {
|
57 79 | Self {
|
58 80 | inner: Inner::V2023_11_09,
|
59 81 | }
|
60 82 | }
|
61 83 |
|
62 84 | /// True if this version is newer or equal to the given `other` version.
|
63 85 | pub fn is_at_least(&self, other: BehaviorVersion) -> bool {
|
64 86 | self.inner >= other.inner
|
65 87 | }
|
66 88 | }
|
67 89 |
|
68 90 | impl std::fmt::Debug for BehaviorVersion {
|
69 91 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
70 92 | f.debug_tuple("BehaviorVersion").field(&self.inner).finish()
|
71 93 | }
|
72 94 | }
|
73 95 |
|
74 96 | #[cfg(test)]
|
75 97 | mod tests {
|
76 98 | use super::*;
|
77 99 |
|
78 100 | #[test]
|
79 101 | #[allow(deprecated)]
|
80 102 | fn version_comparison() {
|
81 103 | assert!(BehaviorVersion::latest() == BehaviorVersion::latest());
|
82 104 | assert!(BehaviorVersion::v2023_11_09() == BehaviorVersion::v2023_11_09());
|
83 105 | assert!(BehaviorVersion::v2024_03_28() != BehaviorVersion::v2023_11_09());
|
106 + | assert!(BehaviorVersion::v2025_01_17() != BehaviorVersion::v2024_03_28());
|
84 107 | assert!(BehaviorVersion::latest().is_at_least(BehaviorVersion::latest()));
|
85 108 | assert!(BehaviorVersion::latest().is_at_least(BehaviorVersion::v2023_11_09()));
|
86 109 | assert!(BehaviorVersion::latest().is_at_least(BehaviorVersion::v2024_03_28()));
|
110 + | assert!(BehaviorVersion::latest().is_at_least(BehaviorVersion::v2025_01_17()));
|
87 111 | assert!(!BehaviorVersion::v2023_11_09().is_at_least(BehaviorVersion::v2024_03_28()));
|
88 112 | assert!(Inner::V2024_03_28 > Inner::V2023_11_09);
|
89 113 | assert!(Inner::V2023_11_09 < Inner::V2024_03_28);
|
114 + | assert!(Inner::V2024_03_28 < Inner::V2025_01_17);
|
90 115 | }
|
91 116 | }
|