1use aws_smithy_types::config_bag::{Storable, StoreReplace};
9use std::borrow::Cow;
10use std::fmt::{Display, Formatter};
11
12#[derive(Clone, Debug, PartialEq, Eq, Hash)]
21pub struct Region(
22 Cow<'static, str>,
25);
26
27impl AsRef<str> for Region {
28 fn as_ref(&self) -> &str {
29 &self.0
30 }
31}
32
33impl Display for Region {
34 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
35 write!(f, "{}", self.0)
36 }
37}
38
39impl Storable for Region {
40 type Storer = StoreReplace<Region>;
41}
42
43impl Region {
44 pub fn new(region: impl Into<Cow<'static, str>>) -> Self {
46 Self(region.into())
47 }
48
49 pub const fn from_static(region: &'static str) -> Self {
51 Self(Cow::Borrowed(region))
52 }
53}
54
55#[derive(Clone, Debug, PartialEq, Eq)]
59pub struct SigningRegion(Cow<'static, str>);
60
61impl AsRef<str> for SigningRegion {
62 fn as_ref(&self) -> &str {
63 &self.0
64 }
65}
66
67impl From<Region> for SigningRegion {
68 fn from(inp: Region) -> Self {
69 SigningRegion(inp.0)
70 }
71}
72
73impl From<&'static str> for SigningRegion {
74 fn from(region: &'static str) -> Self {
75 Self::from_static(region)
76 }
77}
78
79impl SigningRegion {
80 pub const fn from_static(region: &'static str) -> Self {
82 SigningRegion(Cow::Borrowed(region))
83 }
84}
85
86impl Storable for SigningRegion {
87 type Storer = StoreReplace<Self>;
88}
89
90#[derive(Clone, Debug, PartialEq, Eq)]
94pub struct SigningRegionSet(Cow<'static, str>);
95
96impl From<Region> for SigningRegionSet {
97 fn from(inp: Region) -> Self {
98 SigningRegionSet(inp.0)
99 }
100}
101
102impl From<&'static str> for SigningRegionSet {
103 fn from(region: &'static str) -> Self {
104 SigningRegionSet(Cow::Borrowed(region))
105 }
106}
107
108impl<'a> FromIterator<&'a str> for SigningRegionSet {
109 fn from_iter<T: IntoIterator<Item = &'a str>>(iter: T) -> Self {
110 let mut s = String::new();
111 let mut iter = iter.into_iter();
112
113 if let Some(region) = iter.next() {
114 s.push_str(region);
115 }
116
117 for region in iter {
119 s.push(',');
120 s.push_str(region);
121 }
122
123 SigningRegionSet(Cow::Owned(s))
124 }
125}
126
127impl Storable for SigningRegionSet {
128 type Storer = StoreReplace<Self>;
129}
130
131impl AsRef<str> for SigningRegionSet {
132 fn as_ref(&self) -> &str {
133 self.0.as_ref()
134 }
135}