1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 - |
|
3 - | /// Describes one specific validation failure for an input member.
|
4 - | #[derive(
|
5 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
6 - | )]
|
7 - | pub struct ValidationExceptionField {
|
8 - | /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
|
9 - | pub path: ::std::string::String,
|
10 - | /// A detailed description of the validation failure.
|
11 - | pub message: ::std::string::String,
|
12 - | }
|
13 - | impl ValidationExceptionField {
|
14 - | /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
|
15 - | pub fn path(&self) -> &str {
|
16 - | use std::ops::Deref;
|
17 - | self.path.deref()
|
18 - | }
|
19 - | /// A detailed description of the validation failure.
|
20 - | pub fn message(&self) -> &str {
|
21 - | use std::ops::Deref;
|
22 - | self.message.deref()
|
23 - | }
|
24 - | }
|
25 - | impl ValidationExceptionField {
|
26 - | /// Creates a new builder-style object to manufacture [`ValidationExceptionField`](crate::model::ValidationExceptionField).
|
27 - | pub fn builder() -> crate::model::validation_exception_field::Builder {
|
28 - | crate::model::validation_exception_field::Builder::default()
|
29 - | }
|
30 - | }
|
31 - |
|
32 - | #[allow(missing_docs)] // documentation missing in model
|
33 - | ///
|
34 - | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
35 - | /// [constraint traits]. Use [`SensitivePatternString::try_from`] to construct values of this type.
|
36 - | ///
|
37 - | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
38 - | ///
|
39 - | #[derive(
|
40 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
41 - | )]
|
42 - | pub struct SensitivePatternString(pub(crate) ::std::string::String);
|
43 - | impl SensitivePatternString {
|
44 - | /// Extracts a string slice containing the entire underlying `String`.
|
45 - | pub fn as_str(&self) -> &str {
|
46 - | &self.0
|
47 - | }
|
48 - |
|
49 - | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
50 - | pub fn inner(&self) -> &::std::string::String {
|
51 - | &self.0
|
52 - | }
|
53 - |
|
54 - | /// Consumes the value, returning the underlying [`::std::string::String`].
|
55 - | pub fn into_inner(self) -> ::std::string::String {
|
56 - | self.0
|
57 - | }
|
58 - | }
|
59 - | impl SensitivePatternString {
|
60 - | fn check_pattern(
|
61 - | string: ::std::string::String,
|
62 - | ) -> ::std::result::Result<
|
63 - | ::std::string::String,
|
64 - | crate::model::sensitive_pattern_string::ConstraintViolation,
|
65 - | > {
|
66 - | let regex = Self::compile_regex();
|
67 - |
|
68 - | if regex.is_match(&string) {
|
69 - | Ok(string)
|
70 - | } else {
|
71 - | Err(crate::model::sensitive_pattern_string::ConstraintViolation::Pattern(string))
|
72 - | }
|
73 - | }
|
74 - |
|
75 - | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
76 - | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
77 - | pub fn compile_regex() -> &'static ::regex::Regex {
|
78 - | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
79 - | ::regex::Regex::new(r#"^[a-m]+$"#).expect(r#"The regular expression ^[a-m]+$ is not supported by the `regex` crate; feel free to file an issue under https://github.com/smithy-lang/smithy-rs/issues for support"#)
|
80 - | });
|
81 - |
|
82 - | ®EX
|
83 - | }
|
84 - | }
|
85 - | impl ::std::convert::TryFrom<::std::string::String> for SensitivePatternString {
|
86 - | type Error = crate::model::sensitive_pattern_string::ConstraintViolation;
|
87 - |
|
88 - | /// Constructs a `SensitivePatternString` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
89 - | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
90 - | let value = Self::check_pattern(value)?;
|
91 - |
|
92 - | Ok(Self(value))
|
93 - | }
|
94 - | }
|
95 - | impl crate::constrained::Constrained for SensitivePatternString {
|
96 - | type Unconstrained = ::std::string::String;
|
97 - | }
|
98 - |
|
99 - | impl ::std::convert::From<::std::string::String>
|
100 - | for crate::constrained::MaybeConstrained<crate::model::SensitivePatternString>
|
101 - | {
|
102 - | fn from(value: ::std::string::String) -> Self {
|
103 - | Self::Unconstrained(value)
|
104 - | }
|
105 - | }
|
106 - |
|
107 - | impl ::std::fmt::Display for SensitivePatternString {
|
108 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
109 - | "*** Sensitive Data Redacted ***".fmt(f)
|
110 - | }
|
111 - | }
|
112 - |
|
113 - | impl ::std::convert::From<SensitivePatternString> for ::std::string::String {
|
114 - | fn from(value: SensitivePatternString) -> Self {
|
115 - | value.into_inner()
|
116 - | }
|
117 - | }
|
118 - |
|
119 - | #[cfg(test)]
|
120 - | mod test_sensitive_pattern_string {
|
121 - | #[test]
|
122 - | fn regex_compiles() {
|
123 - | crate::model::SensitivePatternString::compile_regex();
|
124 - | }
|
125 - | }
|
126 - |
|
127 - | #[allow(missing_docs)] // documentation missing in model
|
128 - | #[derive(
|
129 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
130 - | )]
|
131 - | pub enum RecursiveUnionOne {
|
132 - | #[allow(missing_docs)] // documentation missing in model
|
133 - | String(crate::model::RecursiveEnumString),
|
134 - | #[allow(missing_docs)] // documentation missing in model
|
135 - | Union(::std::boxed::Box<crate::model::RecursiveUnionTwo>),
|
136 - | }
|
137 - | impl RecursiveUnionOne {
|
138 - | /// Tries to convert the enum instance into [`String`](crate::model::RecursiveUnionOne::String), extracting the inner [`RecursiveEnumString`](crate::model::RecursiveEnumString).
|
139 - | /// Returns `Err(&Self)` if it can't be converted.
|
140 - | pub fn as_string(&self) -> ::std::result::Result<&crate::model::RecursiveEnumString, &Self> {
|
141 - | if let RecursiveUnionOne::String(val) = &self {
|
142 - | ::std::result::Result::Ok(val)
|
143 - | } else {
|
144 - | ::std::result::Result::Err(self)
|
145 - | }
|
146 - | }
|
147 - | /// Returns true if this is a [`String`](crate::model::RecursiveUnionOne::String).
|
148 - | pub fn is_string(&self) -> bool {
|
149 - | self.as_string().is_ok()
|
150 - | }
|
151 - | /// Tries to convert the enum instance into [`Union`](crate::model::RecursiveUnionOne::Union), extracting the inner [`RecursiveUnionTwo`](crate::model::RecursiveUnionTwo).
|
152 - | /// Returns `Err(&Self)` if it can't be converted.
|
153 - | pub fn as_union(
|
154 - | &self,
|
155 - | ) -> ::std::result::Result<&::std::boxed::Box<crate::model::RecursiveUnionTwo>, &Self> {
|
156 - | if let RecursiveUnionOne::Union(val) = &self {
|
157 - | ::std::result::Result::Ok(val)
|
158 - | } else {
|
159 - | ::std::result::Result::Err(self)
|
160 - | }
|
161 - | }
|
162 - | /// Returns true if this is a [`Union`](crate::model::RecursiveUnionOne::Union).
|
163 - | pub fn is_union(&self) -> bool {
|
164 - | self.as_union().is_ok()
|
165 - | }
|
166 - | }
|
167 - |
|
168 - | #[allow(missing_docs)] // documentation missing in model
|
169 - | #[derive(
|
170 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
171 - | )]
|
172 - | pub enum RecursiveUnionTwo {
|
173 - | #[allow(missing_docs)] // documentation missing in model
|
174 - | String(crate::model::RecursiveEnumString),
|
175 - | #[allow(missing_docs)] // documentation missing in model
|
176 - | Union(crate::model::RecursiveUnionOne),
|
177 - | }
|
178 - | impl RecursiveUnionTwo {
|
179 - | /// Tries to convert the enum instance into [`String`](crate::model::RecursiveUnionTwo::String), extracting the inner [`RecursiveEnumString`](crate::model::RecursiveEnumString).
|
180 - | /// Returns `Err(&Self)` if it can't be converted.
|
181 - | pub fn as_string(&self) -> ::std::result::Result<&crate::model::RecursiveEnumString, &Self> {
|
182 - | if let RecursiveUnionTwo::String(val) = &self {
|
183 - | ::std::result::Result::Ok(val)
|
184 - | } else {
|
185 - | ::std::result::Result::Err(self)
|
186 - | }
|
187 - | }
|
188 - | /// Returns true if this is a [`String`](crate::model::RecursiveUnionTwo::String).
|
189 - | pub fn is_string(&self) -> bool {
|
190 - | self.as_string().is_ok()
|
191 - | }
|
192 - | /// Tries to convert the enum instance into [`Union`](crate::model::RecursiveUnionTwo::Union), extracting the inner [`RecursiveUnionOne`](crate::model::RecursiveUnionOne).
|
193 - | /// Returns `Err(&Self)` if it can't be converted.
|
194 - | pub fn as_union(&self) -> ::std::result::Result<&crate::model::RecursiveUnionOne, &Self> {
|
195 - | if let RecursiveUnionTwo::Union(val) = &self {
|
196 - | ::std::result::Result::Ok(val)
|
197 - | } else {
|
198 - | ::std::result::Result::Err(self)
|
199 - | }
|
200 - | }
|
201 - | /// Returns true if this is a [`Union`](crate::model::RecursiveUnionTwo::Union).
|
202 - | pub fn is_union(&self) -> bool {
|
203 - | self.as_union().is_ok()
|
204 - | }
|
205 - | }
|
206 - |
|
207 2 | #[allow(missing_docs)] // documentation missing in model
|
208 3 | #[derive(
|
209 4 | ::std::clone::Clone,
|
210 5 | ::std::cmp::Eq,
|
211 6 | ::std::cmp::Ord,
|
212 7 | ::std::cmp::PartialEq,
|
213 8 | ::std::cmp::PartialOrd,
|
214 9 | ::std::fmt::Debug,
|
215 10 | ::std::hash::Hash,
|
216 11 | )]
|
217 - | pub enum RecursiveEnumString {
|
12 + | pub enum EnumString {
|
218 13 | #[allow(missing_docs)] // documentation missing in model
|
219 14 | Abc,
|
220 15 | #[allow(missing_docs)] // documentation missing in model
|
221 16 | Def,
|
17 + | #[allow(missing_docs)] // documentation missing in model
|
18 + | Ghi,
|
19 + | #[allow(missing_docs)] // documentation missing in model
|
20 + | Jkl,
|
222 21 | }
|
223 - | /// See [`RecursiveEnumString`](crate::model::RecursiveEnumString).
|
224 - | pub mod recursive_enum_string {
|
22 + | /// See [`EnumString`](crate::model::EnumString).
|
23 + | pub mod enum_string {
|
225 24 | #[derive(Debug, PartialEq)]
|
226 25 | pub struct ConstraintViolation(pub(crate) ::std::string::String);
|
227 26 |
|
228 27 | impl ::std::fmt::Display for ConstraintViolation {
|
229 28 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
230 29 | write!(
|
231 30 | f,
|
232 - | r#"Value provided for 'aws.protocoltests.restjson.validation#RecursiveEnumString' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]"#
|
31 + | r#"Value provided for 'aws.protocoltests.restjson.validation#EnumString' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, ghi, jkl]"#
|
233 32 | )
|
234 33 | }
|
235 34 | }
|
236 35 |
|
237 36 | impl ::std::error::Error for ConstraintViolation {}
|
238 37 | impl ConstraintViolation {
|
239 38 | pub(crate) fn as_validation_exception_field(
|
240 39 | self,
|
241 40 | path: ::std::string::String,
|
242 41 | ) -> crate::model::ValidationExceptionField {
|
243 42 | crate::model::ValidationExceptionField {
|
244 43 | message: format!(
|
245 - | r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]"#,
|
44 + | r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, ghi, jkl]"#,
|
246 45 | &path
|
247 46 | ),
|
248 47 | path,
|
249 48 | }
|
250 49 | }
|
251 50 | }
|
252 51 | }
|
253 - | impl ::std::convert::TryFrom<&str> for RecursiveEnumString {
|
254 - | type Error = crate::model::recursive_enum_string::ConstraintViolation;
|
52 + | impl ::std::convert::TryFrom<&str> for EnumString {
|
53 + | type Error = crate::model::enum_string::ConstraintViolation;
|
255 54 | fn try_from(
|
256 55 | s: &str,
|
257 56 | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<&str>>::Error> {
|
258 57 | match s {
|
259 - | "abc" => Ok(RecursiveEnumString::Abc),
|
260 - | "def" => Ok(RecursiveEnumString::Def),
|
261 - | _ => Err(crate::model::recursive_enum_string::ConstraintViolation(
|
262 - | s.to_owned(),
|
263 - | )),
|
58 + | "abc" => Ok(EnumString::Abc),
|
59 + | "def" => Ok(EnumString::Def),
|
60 + | "ghi" => Ok(EnumString::Ghi),
|
61 + | "jkl" => Ok(EnumString::Jkl),
|
62 + | _ => Err(crate::model::enum_string::ConstraintViolation(s.to_owned())),
|
264 63 | }
|
265 64 | }
|
266 65 | }
|
267 - | impl ::std::convert::TryFrom<::std::string::String> for RecursiveEnumString {
|
268 - | type Error = crate::model::recursive_enum_string::ConstraintViolation;
|
66 + | impl ::std::convert::TryFrom<::std::string::String> for EnumString {
|
67 + | type Error = crate::model::enum_string::ConstraintViolation;
|
269 68 | fn try_from(
|
270 69 | s: ::std::string::String,
|
271 70 | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<::std::string::String>>::Error>
|
272 71 | {
|
273 72 | s.as_str().try_into()
|
274 73 | }
|
275 74 | }
|
276 - | impl std::str::FromStr for RecursiveEnumString {
|
277 - | type Err = crate::model::recursive_enum_string::ConstraintViolation;
|
75 + | impl std::str::FromStr for EnumString {
|
76 + | type Err = crate::model::enum_string::ConstraintViolation;
|
278 77 | fn from_str(s: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
|
279 78 | Self::try_from(s)
|
280 79 | }
|
281 80 | }
|
282 - | impl RecursiveEnumString {
|
81 + | impl EnumString {
|
283 82 | /// Returns the `&str` value of the enum member.
|
284 83 | pub fn as_str(&self) -> &str {
|
285 84 | match self {
|
286 - | RecursiveEnumString::Abc => "abc",
|
287 - | RecursiveEnumString::Def => "def",
|
85 + | EnumString::Abc => "abc",
|
86 + | EnumString::Def => "def",
|
87 + | EnumString::Ghi => "ghi",
|
88 + | EnumString::Jkl => "jkl",
|
288 89 | }
|
289 90 | }
|
290 91 | /// Returns all the `&str` representations of the enum members.
|
291 92 | pub const fn values() -> &'static [&'static str] {
|
292 - | &["abc", "def"]
|
93 + | &["abc", "def", "ghi", "jkl"]
|
293 94 | }
|
294 95 | }
|
295 - | impl ::std::convert::AsRef<str> for RecursiveEnumString {
|
96 + | impl ::std::convert::AsRef<str> for EnumString {
|
296 97 | fn as_ref(&self) -> &str {
|
297 98 | self.as_str()
|
298 99 | }
|
299 100 | }
|
300 - | impl crate::constrained::Constrained for RecursiveEnumString {
|
101 + | impl crate::constrained::Constrained for EnumString {
|
301 102 | type Unconstrained = ::std::string::String;
|
302 103 | }
|
303 104 |
|
304 105 | impl ::std::convert::From<::std::string::String>
|
305 - | for crate::constrained::MaybeConstrained<crate::model::RecursiveEnumString>
|
106 + | for crate::constrained::MaybeConstrained<crate::model::EnumString>
|
306 107 | {
|
307 108 | fn from(value: ::std::string::String) -> Self {
|
308 109 | Self::Unconstrained(value)
|
309 110 | }
|
310 111 | }
|
311 112 |
|
312 113 | #[allow(missing_docs)] // documentation missing in model
|
313 - | ///
|
314 - | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
315 - | /// [constraint traits]. Use [`UnionSet::try_from`] to construct values of this type.
|
316 - | ///
|
317 - | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
318 - | ///
|
319 114 | #[derive(
|
320 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
115 + | ::std::clone::Clone,
|
116 + | ::std::cmp::Eq,
|
117 + | ::std::cmp::Ord,
|
118 + | ::std::cmp::PartialEq,
|
119 + | ::std::cmp::PartialOrd,
|
120 + | ::std::fmt::Debug,
|
121 + | ::std::hash::Hash,
|
321 122 | )]
|
322 - | pub struct UnionSet(pub(crate) ::std::vec::Vec<crate::model::FooUnion>);
|
323 - | impl UnionSet {
|
324 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<crate::model::FooUnion>`].
|
325 - | pub fn inner(&self) -> &::std::vec::Vec<crate::model::FooUnion> {
|
326 - | &self.0
|
327 - | }
|
328 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<crate::model::FooUnion>`].
|
329 - | pub fn into_inner(self) -> ::std::vec::Vec<crate::model::FooUnion> {
|
330 - | self.0
|
331 - | }
|
123 + | pub enum EnumTraitString {
|
124 + | #[allow(missing_docs)] // documentation missing in model
|
125 + | Abc,
|
126 + | #[allow(missing_docs)] // documentation missing in model
|
127 + | Def,
|
128 + | #[allow(missing_docs)] // documentation missing in model
|
129 + | Ghi,
|
130 + | }
|
131 + | /// See [`EnumTraitString`](crate::model::EnumTraitString).
|
132 + | pub mod enum_trait_string {
|
133 + | #[derive(Debug, PartialEq)]
|
134 + | pub struct ConstraintViolation(pub(crate) ::std::string::String);
|
332 135 |
|
333 - | fn check_unique_items(
|
334 - | items: ::std::vec::Vec<crate::model::FooUnion>,
|
335 - | ) -> ::std::result::Result<
|
336 - | ::std::vec::Vec<crate::model::FooUnion>,
|
337 - | crate::model::union_set::ConstraintViolation,
|
338 - | > {
|
339 - | let mut seen = ::std::collections::HashMap::new();
|
340 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
341 - | for (idx, item) in items.iter().enumerate() {
|
342 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
343 - | duplicate_indices.push(prev_idx);
|
136 + | impl ::std::fmt::Display for ConstraintViolation {
|
137 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
138 + | write!(
|
139 + | f,
|
140 + | r#"Value provided for 'aws.protocoltests.restjson.validation#EnumTraitString' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, ghi]"#
|
141 + | )
|
344 142 | }
|
345 143 | }
|
346 144 |
|
347 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
348 - | for idx in &duplicate_indices {
|
349 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
350 - | last_duplicate_indices.push(prev_idx);
|
145 + | impl ::std::error::Error for ConstraintViolation {}
|
146 + | impl ConstraintViolation {
|
147 + | pub(crate) fn as_validation_exception_field(
|
148 + | self,
|
149 + | path: ::std::string::String,
|
150 + | ) -> crate::model::ValidationExceptionField {
|
151 + | crate::model::ValidationExceptionField {
|
152 + | message: format!(
|
153 + | r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, ghi]"#,
|
154 + | &path
|
155 + | ),
|
156 + | path,
|
351 157 | }
|
352 158 | }
|
353 - | duplicate_indices.extend(last_duplicate_indices);
|
354 - |
|
355 - | if !duplicate_indices.is_empty() {
|
356 - | debug_assert!(duplicate_indices.len() >= 2);
|
357 - | Err(crate::model::union_set::ConstraintViolation::UniqueItems {
|
358 - | duplicate_indices,
|
359 - | original: items,
|
360 - | })
|
361 - | } else {
|
362 - | Ok(items)
|
159 + | }
|
160 + | }
|
161 + | impl ::std::convert::TryFrom<&str> for EnumTraitString {
|
162 + | type Error = crate::model::enum_trait_string::ConstraintViolation;
|
163 + | fn try_from(
|
164 + | s: &str,
|
165 + | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<&str>>::Error> {
|
166 + | match s {
|
167 + | "abc" => Ok(EnumTraitString::Abc),
|
168 + | "def" => Ok(EnumTraitString::Def),
|
169 + | "ghi" => Ok(EnumTraitString::Ghi),
|
170 + | _ => Err(crate::model::enum_trait_string::ConstraintViolation(
|
171 + | s.to_owned(),
|
172 + | )),
|
363 173 | }
|
364 174 | }
|
365 175 | }
|
366 - | impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::FooUnion>> for UnionSet {
|
367 - | type Error = crate::model::union_set::ConstraintViolation;
|
368 - |
|
369 - | /// Constructs a `UnionSet` from an [`::std::vec::Vec<crate::model::FooUnion>`], failing when the provided value does not satisfy the modeled constraints.
|
176 + | impl ::std::convert::TryFrom<::std::string::String> for EnumTraitString {
|
177 + | type Error = crate::model::enum_trait_string::ConstraintViolation;
|
370 178 | fn try_from(
|
371 - | value: ::std::vec::Vec<crate::model::FooUnion>,
|
372 - | ) -> ::std::result::Result<Self, Self::Error> {
|
373 - | let value = Self::check_unique_items(value)?;
|
374 - |
|
375 - | Ok(Self(value))
|
179 + | s: ::std::string::String,
|
180 + | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<::std::string::String>>::Error>
|
181 + | {
|
182 + | s.as_str().try_into()
|
376 183 | }
|
377 184 | }
|
378 - |
|
379 - | impl ::std::convert::From<UnionSet> for ::std::vec::Vec<crate::model::FooUnion> {
|
380 - | fn from(value: UnionSet) -> Self {
|
381 - | value.into_inner()
|
185 + | impl std::str::FromStr for EnumTraitString {
|
186 + | type Err = crate::model::enum_trait_string::ConstraintViolation;
|
187 + | fn from_str(s: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
|
188 + | Self::try_from(s)
|
382 189 | }
|
383 190 | }
|
384 - | impl crate::constrained::Constrained for UnionSet {
|
385 - | type Unconstrained = crate::unconstrained::union_set_unconstrained::UnionSetUnconstrained;
|
191 + | impl EnumTraitString {
|
192 + | /// Returns the `&str` value of the enum member.
|
193 + | pub fn as_str(&self) -> &str {
|
194 + | match self {
|
195 + | EnumTraitString::Abc => "abc",
|
196 + | EnumTraitString::Def => "def",
|
197 + | EnumTraitString::Ghi => "ghi",
|
198 + | }
|
199 + | }
|
200 + | /// Returns all the `&str` representations of the enum members.
|
201 + | pub const fn values() -> &'static [&'static str] {
|
202 + | &["abc", "def", "ghi"]
|
203 + | }
|
204 + | }
|
205 + | impl ::std::convert::AsRef<str> for EnumTraitString {
|
206 + | fn as_ref(&self) -> &str {
|
207 + | self.as_str()
|
208 + | }
|
209 + | }
|
210 + | impl crate::constrained::Constrained for EnumTraitString {
|
211 + | type Unconstrained = ::std::string::String;
|
212 + | }
|
213 + |
|
214 + | impl ::std::convert::From<::std::string::String>
|
215 + | for crate::constrained::MaybeConstrained<crate::model::EnumTraitString>
|
216 + | {
|
217 + | fn from(value: ::std::string::String) -> Self {
|
218 + | Self::Unconstrained(value)
|
219 + | }
|
386 220 | }
|
387 221 |
|
388 222 | #[allow(missing_docs)] // documentation missing in model
|
389 223 | #[derive(
|
390 224 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
391 225 | )]
|
392 - | pub enum FooUnion {
|
226 + | pub enum EnumUnion {
|
393 227 | #[allow(missing_docs)] // documentation missing in model
|
394 - | Integer(i32),
|
228 + | First(crate::model::EnumString),
|
395 229 | #[allow(missing_docs)] // documentation missing in model
|
396 - | String(::std::string::String),
|
230 + | Second(crate::model::EnumString),
|
397 231 | }
|
398 - | impl FooUnion {
|
399 - | /// Tries to convert the enum instance into [`Integer`](crate::model::FooUnion::Integer), extracting the inner [`i32`](i32).
|
232 + | impl EnumUnion {
|
233 + | /// Tries to convert the enum instance into [`First`](crate::model::EnumUnion::First), extracting the inner [`EnumString`](crate::model::EnumString).
|
400 234 | /// Returns `Err(&Self)` if it can't be converted.
|
401 - | pub fn as_integer(&self) -> ::std::result::Result<&i32, &Self> {
|
402 - | if let FooUnion::Integer(val) = &self {
|
235 + | pub fn as_first(&self) -> ::std::result::Result<&crate::model::EnumString, &Self> {
|
236 + | if let EnumUnion::First(val) = &self {
|
403 237 | ::std::result::Result::Ok(val)
|
404 238 | } else {
|
405 239 | ::std::result::Result::Err(self)
|
406 240 | }
|
407 241 | }
|
408 - | /// Returns true if this is a [`Integer`](crate::model::FooUnion::Integer).
|
409 - | pub fn is_integer(&self) -> bool {
|
410 - | self.as_integer().is_ok()
|
242 + | /// Returns true if this is a [`First`](crate::model::EnumUnion::First).
|
243 + | pub fn is_first(&self) -> bool {
|
244 + | self.as_first().is_ok()
|
411 245 | }
|
412 - | /// Tries to convert the enum instance into [`String`](crate::model::FooUnion::String), extracting the inner [`String`](::std::string::String).
|
246 + | /// Tries to convert the enum instance into [`Second`](crate::model::EnumUnion::Second), extracting the inner [`EnumString`](crate::model::EnumString).
|
413 247 | /// Returns `Err(&Self)` if it can't be converted.
|
414 - | pub fn as_string(&self) -> ::std::result::Result<&::std::string::String, &Self> {
|
415 - | if let FooUnion::String(val) = &self {
|
248 + | pub fn as_second(&self) -> ::std::result::Result<&crate::model::EnumString, &Self> {
|
249 + | if let EnumUnion::Second(val) = &self {
|
416 250 | ::std::result::Result::Ok(val)
|
417 251 | } else {
|
418 252 | ::std::result::Result::Err(self)
|
419 253 | }
|
420 254 | }
|
421 - | /// Returns true if this is a [`String`](crate::model::FooUnion::String).
|
422 - | pub fn is_string(&self) -> bool {
|
423 - | self.as_string().is_ok()
|
255 + | /// Returns true if this is a [`Second`](crate::model::EnumUnion::Second).
|
256 + | pub fn is_second(&self) -> bool {
|
257 + | self.as_second().is_ok()
|
424 258 | }
|
425 259 | }
|
426 260 |
|
427 261 | #[allow(missing_docs)] // documentation missing in model
|
428 262 | ///
|
429 263 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
430 - | /// [constraint traits]. Use [`StructureSetWithNoKey::try_from`] to construct values of this type.
|
264 + | /// [constraint traits]. Use [`LengthBlob::try_from`] to construct values of this type.
|
431 265 | ///
|
432 266 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
433 267 | ///
|
434 268 | #[derive(
|
435 269 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
436 270 | )]
|
437 - | pub struct StructureSetWithNoKey(pub(crate) ::std::vec::Vec<crate::model::MissingKeyStructure>);
|
438 - | impl StructureSetWithNoKey {
|
439 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<crate::model::MissingKeyStructure>`].
|
440 - | pub fn inner(&self) -> &::std::vec::Vec<crate::model::MissingKeyStructure> {
|
271 + | pub struct LengthBlob(pub(crate) ::aws_smithy_types::Blob);
|
272 + | impl LengthBlob {
|
273 + | /// Returns an immutable reference to the underlying [`::aws_smithy_types::Blob`].
|
274 + | pub fn inner(&self) -> &::aws_smithy_types::Blob {
|
441 275 | &self.0
|
442 276 | }
|
443 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<crate::model::MissingKeyStructure>`].
|
444 - | pub fn into_inner(self) -> ::std::vec::Vec<crate::model::MissingKeyStructure> {
|
277 + | /// Consumes the value, returning the underlying [`::aws_smithy_types::Blob`].
|
278 + | pub fn into_inner(self) -> ::aws_smithy_types::Blob {
|
445 279 | self.0
|
446 280 | }
|
281 + | }
|
282 + | impl LengthBlob {
|
283 + | fn check_length(
|
284 + | blob: &::aws_smithy_types::Blob,
|
285 + | ) -> ::std::result::Result<(), crate::model::length_blob::ConstraintViolation> {
|
286 + | let length = blob.as_ref().len();
|
447 287 |
|
448 - | fn check_unique_items(
|
449 - | items: ::std::vec::Vec<crate::model::MissingKeyStructure>,
|
450 - | ) -> ::std::result::Result<
|
451 - | ::std::vec::Vec<crate::model::MissingKeyStructure>,
|
452 - | crate::model::structure_set_with_no_key::ConstraintViolation,
|
453 - | > {
|
454 - | let mut seen = ::std::collections::HashMap::new();
|
455 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
456 - | for (idx, item) in items.iter().enumerate() {
|
457 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
458 - | duplicate_indices.push(prev_idx);
|
459 - | }
|
460 - | }
|
461 - |
|
462 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
463 - | for idx in &duplicate_indices {
|
464 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
465 - | last_duplicate_indices.push(prev_idx);
|
466 - | }
|
467 - | }
|
468 - | duplicate_indices.extend(last_duplicate_indices);
|
469 - |
|
470 - | if !duplicate_indices.is_empty() {
|
471 - | debug_assert!(duplicate_indices.len() >= 2);
|
472 - | Err(
|
473 - | crate::model::structure_set_with_no_key::ConstraintViolation::UniqueItems {
|
474 - | duplicate_indices,
|
475 - | original: items,
|
476 - | },
|
477 - | )
|
288 + | if (2..=8).contains(&length) {
|
289 + | Ok(())
|
478 290 | } else {
|
479 - | Ok(items)
|
291 + | Err(crate::model::length_blob::ConstraintViolation::Length(
|
292 + | length,
|
293 + | ))
|
480 294 | }
|
481 295 | }
|
482 296 | }
|
483 - | impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::MissingKeyStructure>>
|
484 - | for StructureSetWithNoKey
|
485 - | {
|
486 - | type Error = crate::model::structure_set_with_no_key::ConstraintViolation;
|
297 + | impl ::std::convert::TryFrom<::aws_smithy_types::Blob> for LengthBlob {
|
298 + | type Error = crate::model::length_blob::ConstraintViolation;
|
487 299 |
|
488 - | /// Constructs a `StructureSetWithNoKey` from an [`::std::vec::Vec<crate::model::MissingKeyStructure>`], failing when the provided value does not satisfy the modeled constraints.
|
489 - | fn try_from(
|
490 - | value: ::std::vec::Vec<crate::model::MissingKeyStructure>,
|
491 - | ) -> ::std::result::Result<Self, Self::Error> {
|
492 - | let value = Self::check_unique_items(value)?;
|
300 + | /// Constructs a `LengthBlob` from an [`::aws_smithy_types::Blob`], failing when the provided value does not satisfy the modeled constraints.
|
301 + | fn try_from(value: ::aws_smithy_types::Blob) -> ::std::result::Result<Self, Self::Error> {
|
302 + | Self::check_length(&value)?;
|
493 303 |
|
494 304 | Ok(Self(value))
|
495 305 | }
|
496 306 | }
|
307 + | impl crate::constrained::Constrained for LengthBlob {
|
308 + | type Unconstrained = ::aws_smithy_types::Blob;
|
309 + | }
|
497 310 |
|
498 - | impl ::std::convert::From<StructureSetWithNoKey>
|
499 - | for ::std::vec::Vec<crate::model::MissingKeyStructure>
|
500 - | {
|
501 - | fn from(value: StructureSetWithNoKey) -> Self {
|
502 - | value.into_inner()
|
311 + | impl ::std::convert::From<::aws_smithy_types::Blob>
|
312 + | for crate::constrained::MaybeConstrained<crate::model::LengthBlob>
|
313 + | {
|
314 + | fn from(value: ::aws_smithy_types::Blob) -> Self {
|
315 + | Self::Unconstrained(value)
|
503 316 | }
|
504 317 | }
|
505 - | impl crate::constrained::Constrained for StructureSetWithNoKey {
|
506 - | type Unconstrained = crate::unconstrained::structure_set_with_no_key_unconstrained::StructureSetWithNoKeyUnconstrained;
|
507 - | }
|
508 318 |
|
509 - | #[allow(missing_docs)] // documentation missing in model
|
510 - | #[derive(
|
511 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
512 - | )]
|
513 - | pub struct MissingKeyStructure {
|
514 - | #[allow(missing_docs)] // documentation missing in model
|
515 - | pub hi: ::std::string::String,
|
516 - | }
|
517 - | impl MissingKeyStructure {
|
518 - | #[allow(missing_docs)] // documentation missing in model
|
519 - | pub fn hi(&self) -> &str {
|
520 - | use std::ops::Deref;
|
521 - | self.hi.deref()
|
522 - | }
|
523 - | }
|
524 - | impl MissingKeyStructure {
|
525 - | /// Creates a new builder-style object to manufacture [`MissingKeyStructure`](crate::model::MissingKeyStructure).
|
526 - | pub fn builder() -> crate::model::missing_key_structure::Builder {
|
527 - | crate::model::missing_key_structure::Builder::default()
|
319 + | impl ::std::convert::From<LengthBlob> for ::aws_smithy_types::Blob {
|
320 + | fn from(value: LengthBlob) -> Self {
|
321 + | value.into_inner()
|
528 322 | }
|
529 323 | }
|
530 - | impl crate::constrained::Constrained for crate::model::MissingKeyStructure {
|
531 - | type Unconstrained = crate::model::missing_key_structure::Builder;
|
532 - | }
|
533 324 |
|
534 325 | #[allow(missing_docs)] // documentation missing in model
|
535 326 | ///
|
536 327 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
537 - | /// [constraint traits]. Use [`StructureSet::try_from`] to construct values of this type.
|
328 + | /// [constraint traits]. Use [`LengthString::try_from`] to construct values of this type.
|
538 329 | ///
|
539 330 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
540 331 | ///
|
541 332 | #[derive(
|
542 333 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
543 334 | )]
|
544 - | pub struct StructureSet(pub(crate) ::std::vec::Vec<crate::model::GreetingStruct>);
|
545 - | impl StructureSet {
|
546 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<crate::model::GreetingStruct>`].
|
547 - | pub fn inner(&self) -> &::std::vec::Vec<crate::model::GreetingStruct> {
|
335 + | pub struct LengthString(pub(crate) ::std::string::String);
|
336 + | impl LengthString {
|
337 + | /// Extracts a string slice containing the entire underlying `String`.
|
338 + | pub fn as_str(&self) -> &str {
|
548 339 | &self.0
|
549 340 | }
|
550 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<crate::model::GreetingStruct>`].
|
551 - | pub fn into_inner(self) -> ::std::vec::Vec<crate::model::GreetingStruct> {
|
552 - | self.0
|
553 - | }
|
554 341 |
|
555 - | fn check_unique_items(
|
556 - | items: ::std::vec::Vec<crate::model::GreetingStruct>,
|
557 - | ) -> ::std::result::Result<
|
558 - | ::std::vec::Vec<crate::model::GreetingStruct>,
|
559 - | crate::model::structure_set::ConstraintViolation,
|
560 - | > {
|
561 - | let mut seen = ::std::collections::HashMap::new();
|
562 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
563 - | for (idx, item) in items.iter().enumerate() {
|
564 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
565 - | duplicate_indices.push(prev_idx);
|
566 - | }
|
342 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
343 + | pub fn inner(&self) -> &::std::string::String {
|
344 + | &self.0
|
567 345 | }
|
568 346 |
|
569 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
570 - | for idx in &duplicate_indices {
|
571 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
572 - | last_duplicate_indices.push(prev_idx);
|
573 - | }
|
347 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
348 + | pub fn into_inner(self) -> ::std::string::String {
|
349 + | self.0
|
574 350 | }
|
575 - | duplicate_indices.extend(last_duplicate_indices);
|
351 + | }
|
352 + | impl LengthString {
|
353 + | fn check_length(
|
354 + | string: &str,
|
355 + | ) -> ::std::result::Result<(), crate::model::length_string::ConstraintViolation> {
|
356 + | let length = string.chars().count();
|
576 357 |
|
577 - | if !duplicate_indices.is_empty() {
|
578 - | debug_assert!(duplicate_indices.len() >= 2);
|
579 - | Err(
|
580 - | crate::model::structure_set::ConstraintViolation::UniqueItems {
|
581 - | duplicate_indices,
|
582 - | original: items,
|
583 - | },
|
584 - | )
|
358 + | if (2..=8).contains(&length) {
|
359 + | Ok(())
|
585 360 | } else {
|
586 - | Ok(items)
|
361 + | Err(crate::model::length_string::ConstraintViolation::Length(
|
362 + | length,
|
363 + | ))
|
587 364 | }
|
588 365 | }
|
589 366 | }
|
590 - | impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::GreetingStruct>> for StructureSet {
|
591 - | type Error = crate::model::structure_set::ConstraintViolation;
|
367 + | impl ::std::convert::TryFrom<::std::string::String> for LengthString {
|
368 + | type Error = crate::model::length_string::ConstraintViolation;
|
592 369 |
|
593 - | /// Constructs a `StructureSet` from an [`::std::vec::Vec<crate::model::GreetingStruct>`], failing when the provided value does not satisfy the modeled constraints.
|
594 - | fn try_from(
|
595 - | value: ::std::vec::Vec<crate::model::GreetingStruct>,
|
596 - | ) -> ::std::result::Result<Self, Self::Error> {
|
597 - | let value = Self::check_unique_items(value)?;
|
370 + | /// Constructs a `LengthString` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
371 + | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
372 + | Self::check_length(&value)?;
|
598 373 |
|
599 374 | Ok(Self(value))
|
600 375 | }
|
601 376 | }
|
377 + | impl crate::constrained::Constrained for LengthString {
|
378 + | type Unconstrained = ::std::string::String;
|
379 + | }
|
602 380 |
|
603 - | impl ::std::convert::From<StructureSet> for ::std::vec::Vec<crate::model::GreetingStruct> {
|
604 - | fn from(value: StructureSet) -> Self {
|
605 - | value.into_inner()
|
381 + | impl ::std::convert::From<::std::string::String>
|
382 + | for crate::constrained::MaybeConstrained<crate::model::LengthString>
|
383 + | {
|
384 + | fn from(value: ::std::string::String) -> Self {
|
385 + | Self::Unconstrained(value)
|
606 386 | }
|
607 387 | }
|
608 - | impl crate::constrained::Constrained for StructureSet {
|
609 - | type Unconstrained =
|
610 - | crate::unconstrained::structure_set_unconstrained::StructureSetUnconstrained;
|
611 - | }
|
612 388 |
|
613 - | #[allow(missing_docs)] // documentation missing in model
|
614 - | #[derive(
|
615 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
616 - | )]
|
617 - | pub struct GreetingStruct {
|
618 - | #[allow(missing_docs)] // documentation missing in model
|
619 - | pub hi: ::std::option::Option<::std::string::String>,
|
620 - | }
|
621 - | impl GreetingStruct {
|
622 - | #[allow(missing_docs)] // documentation missing in model
|
623 - | pub fn hi(&self) -> ::std::option::Option<&str> {
|
624 - | self.hi.as_deref()
|
389 + | impl ::std::fmt::Display for LengthString {
|
390 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
391 + | self.0.fmt(f)
|
625 392 | }
|
626 393 | }
|
627 - | impl GreetingStruct {
|
628 - | /// Creates a new builder-style object to manufacture [`GreetingStruct`](crate::model::GreetingStruct).
|
629 - | pub fn builder() -> crate::model::greeting_struct::Builder {
|
630 - | crate::model::greeting_struct::Builder::default()
|
394 + |
|
395 + | impl ::std::convert::From<LengthString> for ::std::string::String {
|
396 + | fn from(value: LengthString) -> Self {
|
397 + | value.into_inner()
|
631 398 | }
|
632 399 | }
|
633 - | impl crate::constrained::Constrained for crate::model::GreetingStruct {
|
634 - | type Unconstrained = crate::model::greeting_struct::Builder;
|
635 - | }
|
636 400 |
|
637 401 | #[allow(missing_docs)] // documentation missing in model
|
638 402 | ///
|
639 403 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
640 - | /// [constraint traits]. Use [`ListSet::try_from`] to construct values of this type.
|
404 + | /// [constraint traits]. Use [`MinLengthString::try_from`] to construct values of this type.
|
641 405 | ///
|
642 406 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
643 407 | ///
|
644 408 | #[derive(
|
645 409 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
646 410 | )]
|
647 - | pub struct ListSet(pub(crate) ::std::vec::Vec<::std::vec::Vec<::std::string::String>>);
|
648 - | impl ListSet {
|
649 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<::std::vec::Vec::<::std::string::String>>`].
|
650 - | pub fn inner(&self) -> &::std::vec::Vec<::std::vec::Vec<::std::string::String>> {
|
411 + | pub struct MinLengthString(pub(crate) ::std::string::String);
|
412 + | impl MinLengthString {
|
413 + | /// Extracts a string slice containing the entire underlying `String`.
|
414 + | pub fn as_str(&self) -> &str {
|
651 415 | &self.0
|
652 416 | }
|
653 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<::std::vec::Vec::<::std::string::String>>`].
|
654 - | pub fn into_inner(self) -> ::std::vec::Vec<::std::vec::Vec<::std::string::String>> {
|
655 - | self.0
|
656 - | }
|
657 417 |
|
658 - | fn check_unique_items(
|
659 - | items: ::std::vec::Vec<::std::vec::Vec<::std::string::String>>,
|
660 - | ) -> ::std::result::Result<
|
661 - | ::std::vec::Vec<::std::vec::Vec<::std::string::String>>,
|
662 - | crate::model::list_set::ConstraintViolation,
|
663 - | > {
|
664 - | let mut seen = ::std::collections::HashMap::new();
|
665 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
666 - | for (idx, item) in items.iter().enumerate() {
|
667 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
668 - | duplicate_indices.push(prev_idx);
|
669 - | }
|
418 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
419 + | pub fn inner(&self) -> &::std::string::String {
|
420 + | &self.0
|
670 421 | }
|
671 422 |
|
672 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
673 - | for idx in &duplicate_indices {
|
674 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
675 - | last_duplicate_indices.push(prev_idx);
|
676 - | }
|
423 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
424 + | pub fn into_inner(self) -> ::std::string::String {
|
425 + | self.0
|
677 426 | }
|
678 - | duplicate_indices.extend(last_duplicate_indices);
|
427 + | }
|
428 + | impl MinLengthString {
|
429 + | fn check_length(
|
430 + | string: &str,
|
431 + | ) -> ::std::result::Result<(), crate::model::min_length_string::ConstraintViolation> {
|
432 + | let length = string.chars().count();
|
679 433 |
|
680 - | if !duplicate_indices.is_empty() {
|
681 - | debug_assert!(duplicate_indices.len() >= 2);
|
682 - | Err(crate::model::list_set::ConstraintViolation::UniqueItems {
|
683 - | duplicate_indices,
|
684 - | original: items,
|
685 - | })
|
434 + | if 2 <= length {
|
435 + | Ok(())
|
686 436 | } else {
|
687 - | Ok(items)
|
437 + | Err(crate::model::min_length_string::ConstraintViolation::Length(length))
|
688 438 | }
|
689 439 | }
|
690 440 | }
|
691 - | impl ::std::convert::TryFrom<::std::vec::Vec<::std::vec::Vec<::std::string::String>>> for ListSet {
|
692 - | type Error = crate::model::list_set::ConstraintViolation;
|
441 + | impl ::std::convert::TryFrom<::std::string::String> for MinLengthString {
|
442 + | type Error = crate::model::min_length_string::ConstraintViolation;
|
693 443 |
|
694 - | /// Constructs a `ListSet` from an [`::std::vec::Vec<::std::vec::Vec::<::std::string::String>>`], failing when the provided value does not satisfy the modeled constraints.
|
695 - | fn try_from(
|
696 - | value: ::std::vec::Vec<::std::vec::Vec<::std::string::String>>,
|
697 - | ) -> ::std::result::Result<Self, Self::Error> {
|
698 - | let value = Self::check_unique_items(value)?;
|
444 + | /// Constructs a `MinLengthString` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
445 + | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
446 + | Self::check_length(&value)?;
|
699 447 |
|
700 448 | Ok(Self(value))
|
701 449 | }
|
702 450 | }
|
451 + | impl crate::constrained::Constrained for MinLengthString {
|
452 + | type Unconstrained = ::std::string::String;
|
453 + | }
|
703 454 |
|
704 - | impl ::std::convert::From<ListSet> for ::std::vec::Vec<::std::vec::Vec<::std::string::String>> {
|
705 - | fn from(value: ListSet) -> Self {
|
706 - | value.into_inner()
|
455 + | impl ::std::convert::From<::std::string::String>
|
456 + | for crate::constrained::MaybeConstrained<crate::model::MinLengthString>
|
457 + | {
|
458 + | fn from(value: ::std::string::String) -> Self {
|
459 + | Self::Unconstrained(value)
|
707 460 | }
|
708 461 | }
|
709 - | impl crate::constrained::Constrained for ListSet {
|
710 - | type Unconstrained = crate::unconstrained::list_set_unconstrained::ListSetUnconstrained;
|
462 + |
|
463 + | impl ::std::fmt::Display for MinLengthString {
|
464 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
465 + | self.0.fmt(f)
|
466 + | }
|
467 + | }
|
468 + |
|
469 + | impl ::std::convert::From<MinLengthString> for ::std::string::String {
|
470 + | fn from(value: MinLengthString) -> Self {
|
471 + | value.into_inner()
|
472 + | }
|
711 473 | }
|
712 474 |
|
713 475 | #[allow(missing_docs)] // documentation missing in model
|
714 476 | ///
|
715 477 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
716 - | /// [constraint traits]. Use [`IntegerEnumSet::try_from`] to construct values of this type.
|
478 + | /// [constraint traits]. Use [`MaxLengthString::try_from`] to construct values of this type.
|
717 479 | ///
|
718 480 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
719 481 | ///
|
720 482 | #[derive(
|
721 483 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
722 484 | )]
|
723 - | pub struct IntegerEnumSet(pub(crate) ::std::vec::Vec<i32>);
|
724 - | impl IntegerEnumSet {
|
725 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<i32>`].
|
726 - | pub fn inner(&self) -> &::std::vec::Vec<i32> {
|
485 + | pub struct MaxLengthString(pub(crate) ::std::string::String);
|
486 + | impl MaxLengthString {
|
487 + | /// Extracts a string slice containing the entire underlying `String`.
|
488 + | pub fn as_str(&self) -> &str {
|
727 489 | &self.0
|
728 490 | }
|
729 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<i32>`].
|
730 - | pub fn into_inner(self) -> ::std::vec::Vec<i32> {
|
731 - | self.0
|
491 + |
|
492 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
493 + | pub fn inner(&self) -> &::std::string::String {
|
494 + | &self.0
|
732 495 | }
|
733 496 |
|
734 - | fn check_unique_items(
|
735 - | items: ::std::vec::Vec<i32>,
|
736 - | ) -> ::std::result::Result<
|
737 - | ::std::vec::Vec<i32>,
|
738 - | crate::model::integer_enum_set::ConstraintViolation,
|
739 - | > {
|
740 - | let mut seen = ::std::collections::HashMap::new();
|
741 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
742 - | for (idx, item) in items.iter().enumerate() {
|
743 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
744 - | duplicate_indices.push(prev_idx);
|
745 - | }
|
746 - | }
|
747 - |
|
748 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
749 - | for idx in &duplicate_indices {
|
750 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
751 - | last_duplicate_indices.push(prev_idx);
|
752 - | }
|
497 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
498 + | pub fn into_inner(self) -> ::std::string::String {
|
499 + | self.0
|
753 500 | }
|
754 - | duplicate_indices.extend(last_duplicate_indices);
|
501 + | }
|
502 + | impl MaxLengthString {
|
503 + | fn check_length(
|
504 + | string: &str,
|
505 + | ) -> ::std::result::Result<(), crate::model::max_length_string::ConstraintViolation> {
|
506 + | let length = string.chars().count();
|
755 507 |
|
756 - | if !duplicate_indices.is_empty() {
|
757 - | debug_assert!(duplicate_indices.len() >= 2);
|
758 - | Err(
|
759 - | crate::model::integer_enum_set::ConstraintViolation::UniqueItems {
|
760 - | duplicate_indices,
|
761 - | original: items,
|
762 - | },
|
763 - | )
|
508 + | if length <= 8 {
|
509 + | Ok(())
|
764 510 | } else {
|
765 - | Ok(items)
|
511 + | Err(crate::model::max_length_string::ConstraintViolation::Length(length))
|
766 512 | }
|
767 513 | }
|
768 514 | }
|
769 - | impl ::std::convert::TryFrom<::std::vec::Vec<i32>> for IntegerEnumSet {
|
770 - | type Error = crate::model::integer_enum_set::ConstraintViolation;
|
515 + | impl ::std::convert::TryFrom<::std::string::String> for MaxLengthString {
|
516 + | type Error = crate::model::max_length_string::ConstraintViolation;
|
771 517 |
|
772 - | /// Constructs a `IntegerEnumSet` from an [`::std::vec::Vec<i32>`], failing when the provided value does not satisfy the modeled constraints.
|
773 - | fn try_from(value: ::std::vec::Vec<i32>) -> ::std::result::Result<Self, Self::Error> {
|
774 - | let value = Self::check_unique_items(value)?;
|
518 + | /// Constructs a `MaxLengthString` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
519 + | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
520 + | Self::check_length(&value)?;
|
775 521 |
|
776 522 | Ok(Self(value))
|
777 523 | }
|
778 524 | }
|
525 + | impl crate::constrained::Constrained for MaxLengthString {
|
526 + | type Unconstrained = ::std::string::String;
|
527 + | }
|
779 528 |
|
780 - | impl ::std::convert::From<IntegerEnumSet> for ::std::vec::Vec<i32> {
|
781 - | fn from(value: IntegerEnumSet) -> Self {
|
782 - | value.into_inner()
|
529 + | impl ::std::convert::From<::std::string::String>
|
530 + | for crate::constrained::MaybeConstrained<crate::model::MaxLengthString>
|
531 + | {
|
532 + | fn from(value: ::std::string::String) -> Self {
|
533 + | Self::Unconstrained(value)
|
783 534 | }
|
784 535 | }
|
785 - | impl crate::constrained::Constrained for IntegerEnumSet {
|
786 - | type Unconstrained =
|
787 - | crate::unconstrained::integer_enum_set_unconstrained::IntegerEnumSetUnconstrained;
|
536 + |
|
537 + | impl ::std::fmt::Display for MaxLengthString {
|
538 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
539 + | self.0.fmt(f)
|
540 + | }
|
541 + | }
|
542 + |
|
543 + | impl ::std::convert::From<MaxLengthString> for ::std::string::String {
|
544 + | fn from(value: MaxLengthString) -> Self {
|
545 + | value.into_inner()
|
546 + | }
|
788 547 | }
|
789 548 |
|
790 549 | #[allow(missing_docs)] // documentation missing in model
|
791 550 | ///
|
792 551 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
793 - | /// [constraint traits]. Use [`FooEnumSet::try_from`] to construct values of this type.
|
552 + | /// [constraint traits]. Use [`LengthList::try_from`] to construct values of this type.
|
794 553 | ///
|
795 554 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
796 555 | ///
|
797 556 | #[derive(
|
798 557 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
799 558 | )]
|
800 - | pub struct FooEnumSet(pub(crate) ::std::vec::Vec<crate::model::FooEnum>);
|
801 - | impl FooEnumSet {
|
802 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<crate::model::FooEnum>`].
|
803 - | pub fn inner(&self) -> &::std::vec::Vec<crate::model::FooEnum> {
|
559 + | pub struct LengthList(pub(crate) ::std::vec::Vec<crate::model::LengthString>);
|
560 + | impl LengthList {
|
561 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<crate::model::LengthString>`].
|
562 + | pub fn inner(&self) -> &::std::vec::Vec<crate::model::LengthString> {
|
804 563 | &self.0
|
805 564 | }
|
806 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<crate::model::FooEnum>`].
|
807 - | pub fn into_inner(self) -> ::std::vec::Vec<crate::model::FooEnum> {
|
565 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<crate::model::LengthString>`].
|
566 + | pub fn into_inner(self) -> ::std::vec::Vec<crate::model::LengthString> {
|
808 567 | self.0
|
809 568 | }
|
810 569 |
|
811 - | fn check_unique_items(
|
812 - | items: ::std::vec::Vec<crate::model::FooEnum>,
|
813 - | ) -> ::std::result::Result<
|
814 - | ::std::vec::Vec<crate::model::FooEnum>,
|
815 - | crate::model::foo_enum_set::ConstraintViolation,
|
816 - | > {
|
817 - | let mut seen = ::std::collections::HashMap::new();
|
818 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
819 - | for (idx, item) in items.iter().enumerate() {
|
820 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
821 - | duplicate_indices.push(prev_idx);
|
822 - | }
|
823 - | }
|
824 - |
|
825 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
826 - | for idx in &duplicate_indices {
|
827 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
828 - | last_duplicate_indices.push(prev_idx);
|
829 - | }
|
830 - | }
|
831 - | duplicate_indices.extend(last_duplicate_indices);
|
832 - |
|
833 - | if !duplicate_indices.is_empty() {
|
834 - | debug_assert!(duplicate_indices.len() >= 2);
|
835 - | Err(
|
836 - | crate::model::foo_enum_set::ConstraintViolation::UniqueItems {
|
837 - | duplicate_indices,
|
838 - | original: items,
|
839 - | },
|
840 - | )
|
570 + | fn check_length(
|
571 + | length: usize,
|
572 + | ) -> ::std::result::Result<(), crate::model::length_list::ConstraintViolation> {
|
573 + | if (2..=8).contains(&length) {
|
574 + | Ok(())
|
841 575 | } else {
|
842 - | Ok(items)
|
576 + | Err(crate::model::length_list::ConstraintViolation::Length(
|
577 + | length,
|
578 + | ))
|
843 579 | }
|
844 580 | }
|
845 581 | }
|
846 - | impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::FooEnum>> for FooEnumSet {
|
847 - | type Error = crate::model::foo_enum_set::ConstraintViolation;
|
582 + | impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::LengthString>> for LengthList {
|
583 + | type Error = crate::model::length_list::ConstraintViolation;
|
848 584 |
|
849 - | /// Constructs a `FooEnumSet` from an [`::std::vec::Vec<crate::model::FooEnum>`], failing when the provided value does not satisfy the modeled constraints.
|
585 + | /// Constructs a `LengthList` from an [`::std::vec::Vec<crate::model::LengthString>`], failing when the provided value does not satisfy the modeled constraints.
|
850 586 | fn try_from(
|
851 - | value: ::std::vec::Vec<crate::model::FooEnum>,
|
587 + | value: ::std::vec::Vec<crate::model::LengthString>,
|
852 588 | ) -> ::std::result::Result<Self, Self::Error> {
|
853 - | let value = Self::check_unique_items(value)?;
|
589 + | Self::check_length(value.len())?;
|
854 590 |
|
855 591 | Ok(Self(value))
|
856 592 | }
|
857 593 | }
|
858 594 |
|
859 - | impl ::std::convert::From<FooEnumSet> for ::std::vec::Vec<crate::model::FooEnum> {
|
860 - | fn from(value: FooEnumSet) -> Self {
|
595 + | impl ::std::convert::From<LengthList> for ::std::vec::Vec<crate::model::LengthString> {
|
596 + | fn from(value: LengthList) -> Self {
|
861 597 | value.into_inner()
|
862 598 | }
|
863 599 | }
|
864 - | impl crate::constrained::Constrained for FooEnumSet {
|
865 - | type Unconstrained = crate::unconstrained::foo_enum_set_unconstrained::FooEnumSetUnconstrained;
|
600 + | impl crate::constrained::Constrained for LengthList {
|
601 + | type Unconstrained = crate::unconstrained::length_list_unconstrained::LengthListUnconstrained;
|
866 602 | }
|
867 603 |
|
868 604 | #[allow(missing_docs)] // documentation missing in model
|
869 - | #[derive(
|
870 - | ::std::clone::Clone,
|
871 - | ::std::cmp::Eq,
|
872 - | ::std::cmp::Ord,
|
873 - | ::std::cmp::PartialEq,
|
874 - | ::std::cmp::PartialOrd,
|
875 - | ::std::fmt::Debug,
|
876 - | ::std::hash::Hash,
|
877 - | )]
|
878 - | pub enum FooEnum {
|
879 - | #[allow(missing_docs)] // documentation missing in model
|
880 - | Zero,
|
881 - | #[allow(missing_docs)] // documentation missing in model
|
882 - | One,
|
883 - | #[allow(missing_docs)] // documentation missing in model
|
884 - | Bar,
|
885 - | #[allow(missing_docs)] // documentation missing in model
|
886 - | Baz,
|
887 - | #[allow(missing_docs)] // documentation missing in model
|
888 - | Foo,
|
889 - | }
|
890 - | /// See [`FooEnum`](crate::model::FooEnum).
|
891 - | pub mod foo_enum {
|
892 - | #[derive(Debug, PartialEq)]
|
893 - | pub struct ConstraintViolation(pub(crate) ::std::string::String);
|
894 - |
|
895 - | impl ::std::fmt::Display for ConstraintViolation {
|
896 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
897 - | write!(
|
898 - | f,
|
899 - | r#"Value provided for 'aws.protocoltests.shared#FooEnum' failed to satisfy constraint: Member must satisfy enum value set: [Foo, Baz, Bar, 1, 0]"#
|
900 - | )
|
901 - | }
|
605 + | ///
|
606 + | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
607 + | /// [constraint traits]. Use [`LengthMap::try_from`] to construct values of this type.
|
608 + | ///
|
609 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
610 + | ///
|
611 + | #[derive(::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug)]
|
612 + | pub struct LengthMap(
|
613 + | pub(crate) ::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>,
|
614 + | );
|
615 + | impl LengthMap {
|
616 + | /// Returns an immutable reference to the underlying [`::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>`].
|
617 + | pub fn inner(
|
618 + | &self,
|
619 + | ) -> &::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList> {
|
620 + | &self.0
|
902 621 | }
|
903 - |
|
904 - | impl ::std::error::Error for ConstraintViolation {}
|
905 - | impl ConstraintViolation {
|
906 - | pub(crate) fn as_validation_exception_field(
|
622 + | /// Consumes the value, returning the underlying [`::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>`].
|
623 + | pub fn into_inner(
|
907 624 | self,
|
908 - | path: ::std::string::String,
|
909 - | ) -> crate::model::ValidationExceptionField {
|
910 - | crate::model::ValidationExceptionField {
|
911 - | message: format!(
|
912 - | r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [Foo, Baz, Bar, 1, 0]"#,
|
913 - | &path
|
914 - | ),
|
915 - | path,
|
916 - | }
|
917 - | }
|
625 + | ) -> ::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList> {
|
626 + | self.0
|
918 627 | }
|
919 628 | }
|
920 - | impl ::std::convert::TryFrom<&str> for FooEnum {
|
921 - | type Error = crate::model::foo_enum::ConstraintViolation;
|
629 + | impl
|
630 + | ::std::convert::TryFrom<
|
631 + | ::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>,
|
632 + | > for LengthMap
|
633 + | {
|
634 + | type Error = crate::model::length_map::ConstraintViolation;
|
635 + |
|
636 + | /// Constructs a `LengthMap` from an [`::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>`], failing when the provided value does not satisfy the modeled constraints.
|
922 637 | fn try_from(
|
923 - | s: &str,
|
924 - | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<&str>>::Error> {
|
925 - | match s {
|
926 - | "0" => Ok(FooEnum::Zero),
|
927 - | "1" => Ok(FooEnum::One),
|
928 - | "Bar" => Ok(FooEnum::Bar),
|
929 - | "Baz" => Ok(FooEnum::Baz),
|
930 - | "Foo" => Ok(FooEnum::Foo),
|
931 - | _ => Err(crate::model::foo_enum::ConstraintViolation(s.to_owned())),
|
638 + | value: ::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>,
|
639 + | ) -> ::std::result::Result<Self, Self::Error> {
|
640 + | let length = value.len();
|
641 + | if (2..=8).contains(&length) {
|
642 + | Ok(Self(value))
|
643 + | } else {
|
644 + | Err(crate::model::length_map::ConstraintViolation::Length(
|
645 + | length,
|
646 + | ))
|
932 647 | }
|
933 648 | }
|
934 649 | }
|
935 - | impl ::std::convert::TryFrom<::std::string::String> for FooEnum {
|
936 - | type Error = crate::model::foo_enum::ConstraintViolation;
|
937 - | fn try_from(
|
938 - | s: ::std::string::String,
|
939 - | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<::std::string::String>>::Error>
|
940 - | {
|
941 - | s.as_str().try_into()
|
650 + |
|
651 + | impl ::std::convert::From<LengthMap>
|
652 + | for ::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>
|
653 + | {
|
654 + | fn from(value: LengthMap) -> Self {
|
655 + | value.into_inner()
|
942 656 | }
|
943 657 | }
|
944 - | impl std::str::FromStr for FooEnum {
|
945 - | type Err = crate::model::foo_enum::ConstraintViolation;
|
946 - | fn from_str(s: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
|
947 - | Self::try_from(s)
|
948 - | }
|
949 - | }
|
950 - | impl FooEnum {
|
951 - | /// Returns the `&str` value of the enum member.
|
952 - | pub fn as_str(&self) -> &str {
|
953 - | match self {
|
954 - | FooEnum::Zero => "0",
|
955 - | FooEnum::One => "1",
|
956 - | FooEnum::Bar => "Bar",
|
957 - | FooEnum::Baz => "Baz",
|
958 - | FooEnum::Foo => "Foo",
|
959 - | }
|
960 - | }
|
961 - | /// Returns all the `&str` representations of the enum members.
|
962 - | pub const fn values() -> &'static [&'static str] {
|
963 - | &["0", "1", "Bar", "Baz", "Foo"]
|
964 - | }
|
965 - | }
|
966 - | impl ::std::convert::AsRef<str> for FooEnum {
|
967 - | fn as_ref(&self) -> &str {
|
968 - | self.as_str()
|
969 - | }
|
970 - | }
|
971 - | impl crate::constrained::Constrained for FooEnum {
|
972 - | type Unconstrained = ::std::string::String;
|
973 - | }
|
974 - |
|
975 - | impl ::std::convert::From<::std::string::String>
|
976 - | for crate::constrained::MaybeConstrained<crate::model::FooEnum>
|
977 - | {
|
978 - | fn from(value: ::std::string::String) -> Self {
|
979 - | Self::Unconstrained(value)
|
980 - | }
|
658 + | impl crate::constrained::Constrained for LengthMap {
|
659 + | type Unconstrained = crate::unconstrained::length_map_unconstrained::LengthMapUnconstrained;
|
981 660 | }
|
982 661 |
|
983 662 | #[allow(missing_docs)] // documentation missing in model
|
984 663 | ///
|
985 664 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
986 - | /// [constraint traits]. Use [`HttpDateSet::try_from`] to construct values of this type.
|
665 + | /// [constraint traits]. Use [`PatternString::try_from`] to construct values of this type.
|
987 666 | ///
|
988 667 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
989 668 | ///
|
990 669 | #[derive(
|
991 670 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
992 671 | )]
|
993 - | pub struct HttpDateSet(pub(crate) ::std::vec::Vec<::aws_smithy_types::DateTime>);
|
994 - | impl HttpDateSet {
|
995 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<::aws_smithy_types::DateTime>`].
|
996 - | pub fn inner(&self) -> &::std::vec::Vec<::aws_smithy_types::DateTime> {
|
672 + | pub struct PatternString(pub(crate) ::std::string::String);
|
673 + | impl PatternString {
|
674 + | /// Extracts a string slice containing the entire underlying `String`.
|
675 + | pub fn as_str(&self) -> &str {
|
997 676 | &self.0
|
998 677 | }
|
999 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<::aws_smithy_types::DateTime>`].
|
1000 - | pub fn into_inner(self) -> ::std::vec::Vec<::aws_smithy_types::DateTime> {
|
1001 - | self.0
|
678 + |
|
679 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
680 + | pub fn inner(&self) -> &::std::string::String {
|
681 + | &self.0
|
1002 682 | }
|
1003 683 |
|
1004 - | fn check_unique_items(
|
1005 - | items: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
684 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
685 + | pub fn into_inner(self) -> ::std::string::String {
|
686 + | self.0
|
687 + | }
|
688 + | }
|
689 + | impl PatternString {
|
690 + | fn check_pattern(
|
691 + | string: ::std::string::String,
|
1006 692 | ) -> ::std::result::Result<
|
1007 - | ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
1008 - | crate::model::http_date_set::ConstraintViolation,
|
693 + | ::std::string::String,
|
694 + | crate::model::pattern_string::ConstraintViolation,
|
1009 695 | > {
|
1010 - | let mut seen = ::std::collections::HashMap::new();
|
1011 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
1012 - | for (idx, item) in items.iter().enumerate() {
|
1013 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
1014 - | duplicate_indices.push(prev_idx);
|
1015 - | }
|
1016 - | }
|
696 + | let regex = Self::compile_regex();
|
1017 697 |
|
1018 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
1019 - | for idx in &duplicate_indices {
|
1020 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
1021 - | last_duplicate_indices.push(prev_idx);
|
698 + | if regex.is_match(&string) {
|
699 + | Ok(string)
|
700 + | } else {
|
701 + | Err(crate::model::pattern_string::ConstraintViolation::Pattern(
|
702 + | string,
|
703 + | ))
|
1022 704 | }
|
1023 705 | }
|
1024 - | duplicate_indices.extend(last_duplicate_indices);
|
1025 706 |
|
1026 - | if !duplicate_indices.is_empty() {
|
1027 - | debug_assert!(duplicate_indices.len() >= 2);
|
1028 - | Err(
|
1029 - | crate::model::http_date_set::ConstraintViolation::UniqueItems {
|
1030 - | duplicate_indices,
|
1031 - | original: items,
|
1032 - | },
|
1033 - | )
|
1034 - | } else {
|
1035 - | Ok(items)
|
1036 - | }
|
707 + | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
708 + | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
709 + | pub fn compile_regex() -> &'static ::regex::Regex {
|
710 + | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
711 + | ::regex::Regex::new(r#"^[a-m]+$"#).expect(r#"The regular expression ^[a-m]+$ is not supported by the `regex` crate; feel free to file an issue under https://github.com/smithy-lang/smithy-rs/issues for support"#)
|
712 + | });
|
713 + |
|
714 + | ®EX
|
1037 715 | }
|
1038 716 | }
|
1039 - | impl ::std::convert::TryFrom<::std::vec::Vec<::aws_smithy_types::DateTime>> for HttpDateSet {
|
1040 - | type Error = crate::model::http_date_set::ConstraintViolation;
|
717 + | impl ::std::convert::TryFrom<::std::string::String> for PatternString {
|
718 + | type Error = crate::model::pattern_string::ConstraintViolation;
|
1041 719 |
|
1042 - | /// Constructs a `HttpDateSet` from an [`::std::vec::Vec<::aws_smithy_types::DateTime>`], failing when the provided value does not satisfy the modeled constraints.
|
1043 - | fn try_from(
|
1044 - | value: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
1045 - | ) -> ::std::result::Result<Self, Self::Error> {
|
1046 - | let value = Self::check_unique_items(value)?;
|
720 + | /// Constructs a `PatternString` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
721 + | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
722 + | let value = Self::check_pattern(value)?;
|
1047 723 |
|
1048 724 | Ok(Self(value))
|
1049 725 | }
|
1050 726 | }
|
727 + | impl crate::constrained::Constrained for PatternString {
|
728 + | type Unconstrained = ::std::string::String;
|
729 + | }
|
1051 730 |
|
1052 - | impl ::std::convert::From<HttpDateSet> for ::std::vec::Vec<::aws_smithy_types::DateTime> {
|
1053 - | fn from(value: HttpDateSet) -> Self {
|
731 + | impl ::std::convert::From<::std::string::String>
|
732 + | for crate::constrained::MaybeConstrained<crate::model::PatternString>
|
733 + | {
|
734 + | fn from(value: ::std::string::String) -> Self {
|
735 + | Self::Unconstrained(value)
|
736 + | }
|
737 + | }
|
738 + |
|
739 + | impl ::std::fmt::Display for PatternString {
|
740 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
741 + | self.0.fmt(f)
|
742 + | }
|
743 + | }
|
744 + |
|
745 + | impl ::std::convert::From<PatternString> for ::std::string::String {
|
746 + | fn from(value: PatternString) -> Self {
|
1054 747 | value.into_inner()
|
1055 748 | }
|
1056 749 | }
|
1057 - | impl crate::constrained::Constrained for HttpDateSet {
|
1058 - | type Unconstrained =
|
1059 - | crate::unconstrained::http_date_set_unconstrained::HttpDateSetUnconstrained;
|
750 + |
|
751 + | #[cfg(test)]
|
752 + | mod test_pattern_string {
|
753 + | #[test]
|
754 + | fn regex_compiles() {
|
755 + | crate::model::PatternString::compile_regex();
|
756 + | }
|
1060 757 | }
|
1061 758 |
|
1062 759 | #[allow(missing_docs)] // documentation missing in model
|
1063 760 | ///
|
1064 761 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
1065 - | /// [constraint traits]. Use [`DateTimeSet::try_from`] to construct values of this type.
|
762 + | /// [constraint traits]. Use [`EvilString::try_from`] to construct values of this type.
|
1066 763 | ///
|
1067 764 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1068 765 | ///
|
1069 766 | #[derive(
|
1070 767 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1071 768 | )]
|
1072 - | pub struct DateTimeSet(pub(crate) ::std::vec::Vec<::aws_smithy_types::DateTime>);
|
1073 - | impl DateTimeSet {
|
1074 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<::aws_smithy_types::DateTime>`].
|
1075 - | pub fn inner(&self) -> &::std::vec::Vec<::aws_smithy_types::DateTime> {
|
769 + | pub struct EvilString(pub(crate) ::std::string::String);
|
770 + | impl EvilString {
|
771 + | /// Extracts a string slice containing the entire underlying `String`.
|
772 + | pub fn as_str(&self) -> &str {
|
1076 773 | &self.0
|
1077 774 | }
|
1078 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<::aws_smithy_types::DateTime>`].
|
1079 - | pub fn into_inner(self) -> ::std::vec::Vec<::aws_smithy_types::DateTime> {
|
1080 - | self.0
|
1081 - | }
|
1082 775 |
|
1083 - | fn check_unique_items(
|
1084 - | items: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
1085 - | ) -> ::std::result::Result<
|
1086 - | ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
1087 - | crate::model::date_time_set::ConstraintViolation,
|
1088 - | > {
|
1089 - | let mut seen = ::std::collections::HashMap::new();
|
1090 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
1091 - | for (idx, item) in items.iter().enumerate() {
|
1092 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
1093 - | duplicate_indices.push(prev_idx);
|
1094 - | }
|
776 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
777 + | pub fn inner(&self) -> &::std::string::String {
|
778 + | &self.0
|
1095 779 | }
|
1096 780 |
|
1097 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
1098 - | for idx in &duplicate_indices {
|
1099 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
1100 - | last_duplicate_indices.push(prev_idx);
|
1101 - | }
|
781 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
782 + | pub fn into_inner(self) -> ::std::string::String {
|
783 + | self.0
|
1102 784 | }
|
1103 - | duplicate_indices.extend(last_duplicate_indices);
|
785 + | }
|
786 + | impl EvilString {
|
787 + | fn check_pattern(
|
788 + | string: ::std::string::String,
|
789 + | ) -> ::std::result::Result<::std::string::String, crate::model::evil_string::ConstraintViolation>
|
790 + | {
|
791 + | let regex = Self::compile_regex();
|
1104 792 |
|
1105 - | if !duplicate_indices.is_empty() {
|
1106 - | debug_assert!(duplicate_indices.len() >= 2);
|
1107 - | Err(
|
1108 - | crate::model::date_time_set::ConstraintViolation::UniqueItems {
|
1109 - | duplicate_indices,
|
1110 - | original: items,
|
1111 - | },
|
1112 - | )
|
793 + | if regex.is_match(&string) {
|
794 + | Ok(string)
|
1113 795 | } else {
|
1114 - | Ok(items)
|
796 + | Err(crate::model::evil_string::ConstraintViolation::Pattern(
|
797 + | string,
|
798 + | ))
|
1115 799 | }
|
1116 800 | }
|
801 + |
|
802 + | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
803 + | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
804 + | pub fn compile_regex() -> &'static ::regex::Regex {
|
805 + | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
806 + | ::regex::Regex::new(r#"^([0-9]+)+$"#).expect(r#"The regular expression ^([0-9]+)+$ is not supported by the `regex` crate; feel free to file an issue under https://github.com/smithy-lang/smithy-rs/issues for support"#)
|
807 + | });
|
808 + |
|
809 + | ®EX
|
810 + | }
|
1117 811 | }
|
1118 - | impl ::std::convert::TryFrom<::std::vec::Vec<::aws_smithy_types::DateTime>> for DateTimeSet {
|
1119 - | type Error = crate::model::date_time_set::ConstraintViolation;
|
812 + | impl ::std::convert::TryFrom<::std::string::String> for EvilString {
|
813 + | type Error = crate::model::evil_string::ConstraintViolation;
|
1120 814 |
|
1121 - | /// Constructs a `DateTimeSet` from an [`::std::vec::Vec<::aws_smithy_types::DateTime>`], failing when the provided value does not satisfy the modeled constraints.
|
1122 - | fn try_from(
|
1123 - | value: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
1124 - | ) -> ::std::result::Result<Self, Self::Error> {
|
1125 - | let value = Self::check_unique_items(value)?;
|
815 + | /// Constructs a `EvilString` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
816 + | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
817 + | let value = Self::check_pattern(value)?;
|
1126 818 |
|
1127 819 | Ok(Self(value))
|
1128 820 | }
|
1129 821 | }
|
822 + | impl crate::constrained::Constrained for EvilString {
|
823 + | type Unconstrained = ::std::string::String;
|
824 + | }
|
1130 825 |
|
1131 - | impl ::std::convert::From<DateTimeSet> for ::std::vec::Vec<::aws_smithy_types::DateTime> {
|
1132 - | fn from(value: DateTimeSet) -> Self {
|
1133 - | value.into_inner()
|
826 + | impl ::std::convert::From<::std::string::String>
|
827 + | for crate::constrained::MaybeConstrained<crate::model::EvilString>
|
828 + | {
|
829 + | fn from(value: ::std::string::String) -> Self {
|
830 + | Self::Unconstrained(value)
|
1134 831 | }
|
1135 832 | }
|
1136 - | impl crate::constrained::Constrained for DateTimeSet {
|
1137 - | type Unconstrained =
|
1138 - | crate::unconstrained::date_time_set_unconstrained::DateTimeSetUnconstrained;
|
833 + |
|
834 + | impl ::std::fmt::Display for EvilString {
|
835 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
836 + | self.0.fmt(f)
|
837 + | }
|
1139 838 | }
|
1140 839 |
|
1141 - | #[allow(missing_docs)] // documentation missing in model
|
1142 - | ///
|
1143 - | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
1144 - | /// [constraint traits]. Use [`TimestampSet::try_from`] to construct values of this type.
|
1145 - | ///
|
1146 - | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1147 - | ///
|
1148 - | #[derive(
|
1149 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1150 - | )]
|
1151 - | pub struct TimestampSet(pub(crate) ::std::vec::Vec<::aws_smithy_types::DateTime>);
|
1152 - | impl TimestampSet {
|
1153 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<::aws_smithy_types::DateTime>`].
|
1154 - | pub fn inner(&self) -> &::std::vec::Vec<::aws_smithy_types::DateTime> {
|
1155 - | &self.0
|
1156 - | }
|
1157 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<::aws_smithy_types::DateTime>`].
|
1158 - | pub fn into_inner(self) -> ::std::vec::Vec<::aws_smithy_types::DateTime> {
|
1159 - | self.0
|
840 + | impl ::std::convert::From<EvilString> for ::std::string::String {
|
841 + | fn from(value: EvilString) -> Self {
|
842 + | value.into_inner()
|
1160 843 | }
|
844 + | }
|
1161 845 |
|
1162 - | fn check_unique_items(
|
1163 - | items: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
1164 - | ) -> ::std::result::Result<
|
1165 - | ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
1166 - | crate::model::timestamp_set::ConstraintViolation,
|
1167 - | > {
|
1168 - | let mut seen = ::std::collections::HashMap::new();
|
1169 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
1170 - | for (idx, item) in items.iter().enumerate() {
|
1171 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
1172 - | duplicate_indices.push(prev_idx);
|
1173 - | }
|
846 + | #[cfg(test)]
|
847 + | mod test_evil_string {
|
848 + | #[test]
|
849 + | fn regex_compiles() {
|
850 + | crate::model::EvilString::compile_regex();
|
1174 851 | }
|
852 + | }
|
1175 853 |
|
1176 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
1177 - | for idx in &duplicate_indices {
|
1178 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
1179 - | last_duplicate_indices.push(prev_idx);
|
854 + | #[allow(missing_docs)] // documentation missing in model
|
855 + | #[derive(
|
856 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
857 + | )]
|
858 + | pub enum PatternUnion {
|
859 + | #[allow(missing_docs)] // documentation missing in model
|
860 + | First(crate::model::PatternString),
|
861 + | #[allow(missing_docs)] // documentation missing in model
|
862 + | Second(crate::model::PatternString),
|
863 + | }
|
864 + | impl PatternUnion {
|
865 + | /// Tries to convert the enum instance into [`First`](crate::model::PatternUnion::First), extracting the inner [`PatternString`](crate::model::PatternString).
|
866 + | /// Returns `Err(&Self)` if it can't be converted.
|
867 + | pub fn as_first(&self) -> ::std::result::Result<&crate::model::PatternString, &Self> {
|
868 + | if let PatternUnion::First(val) = &self {
|
869 + | ::std::result::Result::Ok(val)
|
870 + | } else {
|
871 + | ::std::result::Result::Err(self)
|
1180 872 | }
|
1181 873 | }
|
1182 - | duplicate_indices.extend(last_duplicate_indices);
|
1183 - |
|
1184 - | if !duplicate_indices.is_empty() {
|
1185 - | debug_assert!(duplicate_indices.len() >= 2);
|
1186 - | Err(
|
1187 - | crate::model::timestamp_set::ConstraintViolation::UniqueItems {
|
1188 - | duplicate_indices,
|
1189 - | original: items,
|
1190 - | },
|
1191 - | )
|
874 + | /// Returns true if this is a [`First`](crate::model::PatternUnion::First).
|
875 + | pub fn is_first(&self) -> bool {
|
876 + | self.as_first().is_ok()
|
877 + | }
|
878 + | /// Tries to convert the enum instance into [`Second`](crate::model::PatternUnion::Second), extracting the inner [`PatternString`](crate::model::PatternString).
|
879 + | /// Returns `Err(&Self)` if it can't be converted.
|
880 + | pub fn as_second(&self) -> ::std::result::Result<&crate::model::PatternString, &Self> {
|
881 + | if let PatternUnion::Second(val) = &self {
|
882 + | ::std::result::Result::Ok(val)
|
1192 883 | } else {
|
1193 - | Ok(items)
|
884 + | ::std::result::Result::Err(self)
|
1194 885 | }
|
1195 886 | }
|
1196 - | }
|
1197 - | impl ::std::convert::TryFrom<::std::vec::Vec<::aws_smithy_types::DateTime>> for TimestampSet {
|
1198 - | type Error = crate::model::timestamp_set::ConstraintViolation;
|
1199 - |
|
1200 - | /// Constructs a `TimestampSet` from an [`::std::vec::Vec<::aws_smithy_types::DateTime>`], failing when the provided value does not satisfy the modeled constraints.
|
1201 - | fn try_from(
|
1202 - | value: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
1203 - | ) -> ::std::result::Result<Self, Self::Error> {
|
1204 - | let value = Self::check_unique_items(value)?;
|
1205 - |
|
1206 - | Ok(Self(value))
|
887 + | /// Returns true if this is a [`Second`](crate::model::PatternUnion::Second).
|
888 + | pub fn is_second(&self) -> bool {
|
889 + | self.as_second().is_ok()
|
1207 890 | }
|
1208 891 | }
|
1209 892 |
|
1210 - | impl ::std::convert::From<TimestampSet> for ::std::vec::Vec<::aws_smithy_types::DateTime> {
|
1211 - | fn from(value: TimestampSet) -> Self {
|
1212 - | value.into_inner()
|
1213 - | }
|
893 + | #[allow(missing_docs)] // documentation missing in model
|
894 + | #[derive(
|
895 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
896 + | )]
|
897 + | pub enum PatternUnionOverride {
|
898 + | #[allow(missing_docs)] // documentation missing in model
|
899 + | First(crate::model::pattern_union_override::First),
|
900 + | #[allow(missing_docs)] // documentation missing in model
|
901 + | Second(crate::model::pattern_union_override::Second),
|
1214 902 | }
|
1215 - | impl crate::constrained::Constrained for TimestampSet {
|
1216 - | type Unconstrained =
|
1217 - | crate::unconstrained::timestamp_set_unconstrained::TimestampSetUnconstrained;
|
903 + | impl PatternUnionOverride {
|
904 + | /// Tries to convert the enum instance into [`First`](crate::model::PatternUnionOverride::First), extracting the inner [`First`](crate::model::pattern_union_override::First).
|
905 + | /// Returns `Err(&Self)` if it can't be converted.
|
906 + | pub fn as_first(
|
907 + | &self,
|
908 + | ) -> ::std::result::Result<&crate::model::pattern_union_override::First, &Self> {
|
909 + | if let PatternUnionOverride::First(val) = &self {
|
910 + | ::std::result::Result::Ok(val)
|
911 + | } else {
|
912 + | ::std::result::Result::Err(self)
|
913 + | }
|
914 + | }
|
915 + | /// Returns true if this is a [`First`](crate::model::PatternUnionOverride::First).
|
916 + | pub fn is_first(&self) -> bool {
|
917 + | self.as_first().is_ok()
|
918 + | }
|
919 + | /// Tries to convert the enum instance into [`Second`](crate::model::PatternUnionOverride::Second), extracting the inner [`Second`](crate::model::pattern_union_override::Second).
|
920 + | /// Returns `Err(&Self)` if it can't be converted.
|
921 + | pub fn as_second(
|
922 + | &self,
|
923 + | ) -> ::std::result::Result<&crate::model::pattern_union_override::Second, &Self> {
|
924 + | if let PatternUnionOverride::Second(val) = &self {
|
925 + | ::std::result::Result::Ok(val)
|
926 + | } else {
|
927 + | ::std::result::Result::Err(self)
|
928 + | }
|
929 + | }
|
930 + | /// Returns true if this is a [`Second`](crate::model::PatternUnionOverride::Second).
|
931 + | pub fn is_second(&self) -> bool {
|
932 + | self.as_second().is_ok()
|
933 + | }
|
1218 934 | }
|
1219 935 |
|
1220 936 | #[allow(missing_docs)] // documentation missing in model
|
1221 937 | ///
|
1222 938 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
1223 - | /// [constraint traits]. Use [`LongSet::try_from`] to construct values of this type.
|
939 + | /// [constraint traits]. Use [`RangeByte::try_from`] to construct values of this type.
|
1224 940 | ///
|
1225 941 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1226 942 | ///
|
1227 943 | #[derive(
|
1228 944 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1229 945 | )]
|
1230 - | pub struct LongSet(pub(crate) ::std::vec::Vec<i64>);
|
1231 - | impl LongSet {
|
1232 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<i64>`].
|
1233 - | pub fn inner(&self) -> &::std::vec::Vec<i64> {
|
946 + | pub struct RangeByte(pub(crate) i8);
|
947 + | impl RangeByte {
|
948 + | /// Returns an immutable reference to the underlying [`i8`].
|
949 + | pub fn inner(&self) -> &i8 {
|
1234 950 | &self.0
|
1235 951 | }
|
1236 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<i64>`].
|
1237 - | pub fn into_inner(self) -> ::std::vec::Vec<i64> {
|
952 + |
|
953 + | /// Consumes the value, returning the underlying [`i8`].
|
954 + | pub fn into_inner(self) -> i8 {
|
1238 955 | self.0
|
1239 956 | }
|
957 + | }
|
1240 958 |
|
1241 - | fn check_unique_items(
|
1242 - | items: ::std::vec::Vec<i64>,
|
1243 - | ) -> ::std::result::Result<::std::vec::Vec<i64>, crate::model::long_set::ConstraintViolation>
|
1244 - | {
|
1245 - | let mut seen = ::std::collections::HashMap::new();
|
1246 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
1247 - | for (idx, item) in items.iter().enumerate() {
|
1248 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
1249 - | duplicate_indices.push(prev_idx);
|
1250 - | }
|
1251 - | }
|
959 + | impl crate::constrained::Constrained for RangeByte {
|
960 + | type Unconstrained = i8;
|
961 + | }
|
1252 962 |
|
1253 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
1254 - | for idx in &duplicate_indices {
|
1255 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
1256 - | last_duplicate_indices.push(prev_idx);
|
963 + | impl ::std::convert::From<i8> for crate::constrained::MaybeConstrained<crate::model::RangeByte> {
|
964 + | fn from(value: i8) -> Self {
|
965 + | Self::Unconstrained(value)
|
1257 966 | }
|
967 + | }
|
968 + |
|
969 + | impl ::std::fmt::Display for RangeByte {
|
970 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
971 + | self.0.fmt(f)
|
1258 972 | }
|
1259 - | duplicate_indices.extend(last_duplicate_indices);
|
973 + | }
|
1260 974 |
|
1261 - | if !duplicate_indices.is_empty() {
|
1262 - | debug_assert!(duplicate_indices.len() >= 2);
|
1263 - | Err(crate::model::long_set::ConstraintViolation::UniqueItems {
|
1264 - | duplicate_indices,
|
1265 - | original: items,
|
1266 - | })
|
975 + | impl ::std::convert::From<RangeByte> for i8 {
|
976 + | fn from(value: RangeByte) -> Self {
|
977 + | value.into_inner()
|
978 + | }
|
979 + | }
|
980 + | impl RangeByte {
|
981 + | fn check_range(
|
982 + | value: i8,
|
983 + | ) -> ::std::result::Result<(), crate::model::range_byte::ConstraintViolation> {
|
984 + | if (2..=8).contains(&value) {
|
985 + | Ok(())
|
1267 986 | } else {
|
1268 - | Ok(items)
|
987 + | Err(crate::model::range_byte::ConstraintViolation::Range(value))
|
1269 988 | }
|
1270 989 | }
|
1271 990 | }
|
1272 - | impl ::std::convert::TryFrom<::std::vec::Vec<i64>> for LongSet {
|
1273 - | type Error = crate::model::long_set::ConstraintViolation;
|
991 + | impl ::std::convert::TryFrom<i8> for RangeByte {
|
992 + | type Error = crate::model::range_byte::ConstraintViolation;
|
1274 993 |
|
1275 - | /// Constructs a `LongSet` from an [`::std::vec::Vec<i64>`], failing when the provided value does not satisfy the modeled constraints.
|
1276 - | fn try_from(value: ::std::vec::Vec<i64>) -> ::std::result::Result<Self, Self::Error> {
|
1277 - | let value = Self::check_unique_items(value)?;
|
994 + | /// Constructs a `RangeByte` from an [`i8`], failing when the provided value does not satisfy the modeled constraints.
|
995 + | fn try_from(value: i8) -> ::std::result::Result<Self, Self::Error> {
|
996 + | Self::check_range(value)?;
|
1278 997 |
|
1279 998 | Ok(Self(value))
|
1280 999 | }
|
1281 1000 | }
|
1282 1001 |
|
1283 - | impl ::std::convert::From<LongSet> for ::std::vec::Vec<i64> {
|
1284 - | fn from(value: LongSet) -> Self {
|
1285 - | value.into_inner()
|
1286 - | }
|
1287 - | }
|
1288 - | impl crate::constrained::Constrained for LongSet {
|
1289 - | type Unconstrained = crate::unconstrained::long_set_unconstrained::LongSetUnconstrained;
|
1290 - | }
|
1291 - |
|
1292 1002 | #[allow(missing_docs)] // documentation missing in model
|
1293 1003 | ///
|
1294 1004 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
1295 - | /// [constraint traits]. Use [`IntegerSet::try_from`] to construct values of this type.
|
1005 + | /// [constraint traits]. Use [`MinByte::try_from`] to construct values of this type.
|
1296 1006 | ///
|
1297 1007 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1298 1008 | ///
|
1299 1009 | #[derive(
|
1300 1010 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1301 1011 | )]
|
1302 - | pub struct IntegerSet(pub(crate) ::std::vec::Vec<i32>);
|
1303 - | impl IntegerSet {
|
1304 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<i32>`].
|
1305 - | pub fn inner(&self) -> &::std::vec::Vec<i32> {
|
1012 + | pub struct MinByte(pub(crate) i8);
|
1013 + | impl MinByte {
|
1014 + | /// Returns an immutable reference to the underlying [`i8`].
|
1015 + | pub fn inner(&self) -> &i8 {
|
1306 1016 | &self.0
|
1307 1017 | }
|
1308 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<i32>`].
|
1309 - | pub fn into_inner(self) -> ::std::vec::Vec<i32> {
|
1018 + |
|
1019 + | /// Consumes the value, returning the underlying [`i8`].
|
1020 + | pub fn into_inner(self) -> i8 {
|
1310 1021 | self.0
|
1311 1022 | }
|
1023 + | }
|
1312 1024 |
|
1313 - | fn check_unique_items(
|
1314 - | items: ::std::vec::Vec<i32>,
|
1315 - | ) -> ::std::result::Result<::std::vec::Vec<i32>, crate::model::integer_set::ConstraintViolation>
|
1316 - | {
|
1317 - | let mut seen = ::std::collections::HashMap::new();
|
1318 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
1319 - | for (idx, item) in items.iter().enumerate() {
|
1320 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
1321 - | duplicate_indices.push(prev_idx);
|
1025 + | impl crate::constrained::Constrained for MinByte {
|
1026 + | type Unconstrained = i8;
|
1027 + | }
|
1028 + |
|
1029 + | impl ::std::convert::From<i8> for crate::constrained::MaybeConstrained<crate::model::MinByte> {
|
1030 + | fn from(value: i8) -> Self {
|
1031 + | Self::Unconstrained(value)
|
1322 1032 | }
|
1033 + | }
|
1034 + |
|
1035 + | impl ::std::fmt::Display for MinByte {
|
1036 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1037 + | self.0.fmt(f)
|
1323 1038 | }
|
1039 + | }
|
1324 1040 |
|
1325 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
1326 - | for idx in &duplicate_indices {
|
1327 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
1328 - | last_duplicate_indices.push(prev_idx);
|
1329 - | }
|
1041 + | impl ::std::convert::From<MinByte> for i8 {
|
1042 + | fn from(value: MinByte) -> Self {
|
1043 + | value.into_inner()
|
1330 1044 | }
|
1331 - | duplicate_indices.extend(last_duplicate_indices);
|
1332 - |
|
1333 - | if !duplicate_indices.is_empty() {
|
1334 - | debug_assert!(duplicate_indices.len() >= 2);
|
1335 - | Err(
|
1336 - | crate::model::integer_set::ConstraintViolation::UniqueItems {
|
1337 - | duplicate_indices,
|
1338 - | original: items,
|
1339 - | },
|
1340 - | )
|
1045 + | }
|
1046 + | impl MinByte {
|
1047 + | fn check_range(
|
1048 + | value: i8,
|
1049 + | ) -> ::std::result::Result<(), crate::model::min_byte::ConstraintViolation> {
|
1050 + | if 2 <= value {
|
1051 + | Ok(())
|
1341 1052 | } else {
|
1342 - | Ok(items)
|
1053 + | Err(crate::model::min_byte::ConstraintViolation::Range(value))
|
1343 1054 | }
|
1344 1055 | }
|
1345 1056 | }
|
1346 - | impl ::std::convert::TryFrom<::std::vec::Vec<i32>> for IntegerSet {
|
1347 - | type Error = crate::model::integer_set::ConstraintViolation;
|
1057 + | impl ::std::convert::TryFrom<i8> for MinByte {
|
1058 + | type Error = crate::model::min_byte::ConstraintViolation;
|
1348 1059 |
|
1349 - | /// Constructs a `IntegerSet` from an [`::std::vec::Vec<i32>`], failing when the provided value does not satisfy the modeled constraints.
|
1350 - | fn try_from(value: ::std::vec::Vec<i32>) -> ::std::result::Result<Self, Self::Error> {
|
1351 - | let value = Self::check_unique_items(value)?;
|
1060 + | /// Constructs a `MinByte` from an [`i8`], failing when the provided value does not satisfy the modeled constraints.
|
1061 + | fn try_from(value: i8) -> ::std::result::Result<Self, Self::Error> {
|
1062 + | Self::check_range(value)?;
|
1352 1063 |
|
1353 1064 | Ok(Self(value))
|
1354 1065 | }
|
1355 1066 | }
|
1356 1067 |
|
1357 - | impl ::std::convert::From<IntegerSet> for ::std::vec::Vec<i32> {
|
1358 - | fn from(value: IntegerSet) -> Self {
|
1359 - | value.into_inner()
|
1360 - | }
|
1361 - | }
|
1362 - | impl crate::constrained::Constrained for IntegerSet {
|
1363 - | type Unconstrained = crate::unconstrained::integer_set_unconstrained::IntegerSetUnconstrained;
|
1364 - | }
|
1365 - |
|
1366 1068 | #[allow(missing_docs)] // documentation missing in model
|
1367 1069 | ///
|
1368 1070 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
1369 - | /// [constraint traits]. Use [`ShortSet::try_from`] to construct values of this type.
|
1071 + | /// [constraint traits]. Use [`MaxByte::try_from`] to construct values of this type.
|
1370 1072 | ///
|
1371 1073 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1372 1074 | ///
|
1373 1075 | #[derive(
|
1374 1076 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1375 1077 | )]
|
1376 - | pub struct ShortSet(pub(crate) ::std::vec::Vec<i16>);
|
1377 - | impl ShortSet {
|
1378 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<i16>`].
|
1379 - | pub fn inner(&self) -> &::std::vec::Vec<i16> {
|
1078 + | pub struct MaxByte(pub(crate) i8);
|
1079 + | impl MaxByte {
|
1080 + | /// Returns an immutable reference to the underlying [`i8`].
|
1081 + | pub fn inner(&self) -> &i8 {
|
1380 1082 | &self.0
|
1381 1083 | }
|
1382 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<i16>`].
|
1383 - | pub fn into_inner(self) -> ::std::vec::Vec<i16> {
|
1084 + |
|
1085 + | /// Consumes the value, returning the underlying [`i8`].
|
1086 + | pub fn into_inner(self) -> i8 {
|
1384 1087 | self.0
|
1385 1088 | }
|
1089 + | }
|
1386 1090 |
|
1387 - | fn check_unique_items(
|
1388 - | items: ::std::vec::Vec<i16>,
|
1389 - | ) -> ::std::result::Result<::std::vec::Vec<i16>, crate::model::short_set::ConstraintViolation>
|
1390 - | {
|
1391 - | let mut seen = ::std::collections::HashMap::new();
|
1392 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
1393 - | for (idx, item) in items.iter().enumerate() {
|
1394 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
1395 - | duplicate_indices.push(prev_idx);
|
1396 - | }
|
1397 - | }
|
1091 + | impl crate::constrained::Constrained for MaxByte {
|
1092 + | type Unconstrained = i8;
|
1093 + | }
|
1398 1094 |
|
1399 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
1400 - | for idx in &duplicate_indices {
|
1401 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
1402 - | last_duplicate_indices.push(prev_idx);
|
1095 + | impl ::std::convert::From<i8> for crate::constrained::MaybeConstrained<crate::model::MaxByte> {
|
1096 + | fn from(value: i8) -> Self {
|
1097 + | Self::Unconstrained(value)
|
1403 1098 | }
|
1099 + | }
|
1100 + |
|
1101 + | impl ::std::fmt::Display for MaxByte {
|
1102 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1103 + | self.0.fmt(f)
|
1404 1104 | }
|
1405 - | duplicate_indices.extend(last_duplicate_indices);
|
1105 + | }
|
1406 1106 |
|
1407 - | if !duplicate_indices.is_empty() {
|
1408 - | debug_assert!(duplicate_indices.len() >= 2);
|
1409 - | Err(crate::model::short_set::ConstraintViolation::UniqueItems {
|
1410 - | duplicate_indices,
|
1411 - | original: items,
|
1412 - | })
|
1107 + | impl ::std::convert::From<MaxByte> for i8 {
|
1108 + | fn from(value: MaxByte) -> Self {
|
1109 + | value.into_inner()
|
1110 + | }
|
1111 + | }
|
1112 + | impl MaxByte {
|
1113 + | fn check_range(
|
1114 + | value: i8,
|
1115 + | ) -> ::std::result::Result<(), crate::model::max_byte::ConstraintViolation> {
|
1116 + | if value <= 8 {
|
1117 + | Ok(())
|
1413 1118 | } else {
|
1414 - | Ok(items)
|
1119 + | Err(crate::model::max_byte::ConstraintViolation::Range(value))
|
1415 1120 | }
|
1416 1121 | }
|
1417 1122 | }
|
1418 - | impl ::std::convert::TryFrom<::std::vec::Vec<i16>> for ShortSet {
|
1419 - | type Error = crate::model::short_set::ConstraintViolation;
|
1123 + | impl ::std::convert::TryFrom<i8> for MaxByte {
|
1124 + | type Error = crate::model::max_byte::ConstraintViolation;
|
1420 1125 |
|
1421 - | /// Constructs a `ShortSet` from an [`::std::vec::Vec<i16>`], failing when the provided value does not satisfy the modeled constraints.
|
1422 - | fn try_from(value: ::std::vec::Vec<i16>) -> ::std::result::Result<Self, Self::Error> {
|
1423 - | let value = Self::check_unique_items(value)?;
|
1126 + | /// Constructs a `MaxByte` from an [`i8`], failing when the provided value does not satisfy the modeled constraints.
|
1127 + | fn try_from(value: i8) -> ::std::result::Result<Self, Self::Error> {
|
1128 + | Self::check_range(value)?;
|
1424 1129 |
|
1425 1130 | Ok(Self(value))
|
1426 1131 | }
|
1427 1132 | }
|
1428 1133 |
|
1429 - | impl ::std::convert::From<ShortSet> for ::std::vec::Vec<i16> {
|
1430 - | fn from(value: ShortSet) -> Self {
|
1431 - | value.into_inner()
|
1432 - | }
|
1433 - | }
|
1434 - | impl crate::constrained::Constrained for ShortSet {
|
1435 - | type Unconstrained = crate::unconstrained::short_set_unconstrained::ShortSetUnconstrained;
|
1436 - | }
|
1437 - |
|
1438 1134 | #[allow(missing_docs)] // documentation missing in model
|
1439 1135 | ///
|
1440 1136 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
1441 - | /// [constraint traits]. Use [`ByteSet::try_from`] to construct values of this type.
|
1137 + | /// [constraint traits]. Use [`RangeShort::try_from`] to construct values of this type.
|
1442 1138 | ///
|
1443 1139 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1444 1140 | ///
|
1445 1141 | #[derive(
|
1446 1142 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1447 1143 | )]
|
1448 - | pub struct ByteSet(pub(crate) ::std::vec::Vec<i8>);
|
1449 - | impl ByteSet {
|
1450 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<i8>`].
|
1451 - | pub fn inner(&self) -> &::std::vec::Vec<i8> {
|
1144 + | pub struct RangeShort(pub(crate) i16);
|
1145 + | impl RangeShort {
|
1146 + | /// Returns an immutable reference to the underlying [`i16`].
|
1147 + | pub fn inner(&self) -> &i16 {
|
1452 1148 | &self.0
|
1453 1149 | }
|
1454 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<i8>`].
|
1455 - | pub fn into_inner(self) -> ::std::vec::Vec<i8> {
|
1150 + |
|
1151 + | /// Consumes the value, returning the underlying [`i16`].
|
1152 + | pub fn into_inner(self) -> i16 {
|
1456 1153 | self.0
|
1457 1154 | }
|
1155 + | }
|
1458 1156 |
|
1459 - | fn check_unique_items(
|
1460 - | items: ::std::vec::Vec<i8>,
|
1461 - | ) -> ::std::result::Result<::std::vec::Vec<i8>, crate::model::byte_set::ConstraintViolation>
|
1462 - | {
|
1463 - | let mut seen = ::std::collections::HashMap::new();
|
1464 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
1465 - | for (idx, item) in items.iter().enumerate() {
|
1466 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
1467 - | duplicate_indices.push(prev_idx);
|
1468 - | }
|
1469 - | }
|
1157 + | impl crate::constrained::Constrained for RangeShort {
|
1158 + | type Unconstrained = i16;
|
1159 + | }
|
1470 1160 |
|
1471 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
1472 - | for idx in &duplicate_indices {
|
1473 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
1474 - | last_duplicate_indices.push(prev_idx);
|
1161 + | impl ::std::convert::From<i16> for crate::constrained::MaybeConstrained<crate::model::RangeShort> {
|
1162 + | fn from(value: i16) -> Self {
|
1163 + | Self::Unconstrained(value)
|
1475 1164 | }
|
1165 + | }
|
1166 + |
|
1167 + | impl ::std::fmt::Display for RangeShort {
|
1168 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1169 + | self.0.fmt(f)
|
1476 1170 | }
|
1477 - | duplicate_indices.extend(last_duplicate_indices);
|
1171 + | }
|
1478 1172 |
|
1479 - | if !duplicate_indices.is_empty() {
|
1480 - | debug_assert!(duplicate_indices.len() >= 2);
|
1481 - | Err(crate::model::byte_set::ConstraintViolation::UniqueItems {
|
1482 - | duplicate_indices,
|
1483 - | original: items,
|
1484 - | })
|
1173 + | impl ::std::convert::From<RangeShort> for i16 {
|
1174 + | fn from(value: RangeShort) -> Self {
|
1175 + | value.into_inner()
|
1176 + | }
|
1177 + | }
|
1178 + | impl RangeShort {
|
1179 + | fn check_range(
|
1180 + | value: i16,
|
1181 + | ) -> ::std::result::Result<(), crate::model::range_short::ConstraintViolation> {
|
1182 + | if (2..=8).contains(&value) {
|
1183 + | Ok(())
|
1485 1184 | } else {
|
1486 - | Ok(items)
|
1185 + | Err(crate::model::range_short::ConstraintViolation::Range(value))
|
1487 1186 | }
|
1488 1187 | }
|
1489 1188 | }
|
1490 - | impl ::std::convert::TryFrom<::std::vec::Vec<i8>> for ByteSet {
|
1491 - | type Error = crate::model::byte_set::ConstraintViolation;
|
1189 + | impl ::std::convert::TryFrom<i16> for RangeShort {
|
1190 + | type Error = crate::model::range_short::ConstraintViolation;
|
1492 1191 |
|
1493 - | /// Constructs a `ByteSet` from an [`::std::vec::Vec<i8>`], failing when the provided value does not satisfy the modeled constraints.
|
1494 - | fn try_from(value: ::std::vec::Vec<i8>) -> ::std::result::Result<Self, Self::Error> {
|
1495 - | let value = Self::check_unique_items(value)?;
|
1192 + | /// Constructs a `RangeShort` from an [`i16`], failing when the provided value does not satisfy the modeled constraints.
|
1193 + | fn try_from(value: i16) -> ::std::result::Result<Self, Self::Error> {
|
1194 + | Self::check_range(value)?;
|
1496 1195 |
|
1497 1196 | Ok(Self(value))
|
1498 1197 | }
|
1499 1198 | }
|
1500 1199 |
|
1501 - | impl ::std::convert::From<ByteSet> for ::std::vec::Vec<i8> {
|
1502 - | fn from(value: ByteSet) -> Self {
|
1503 - | value.into_inner()
|
1504 - | }
|
1505 - | }
|
1506 - | impl crate::constrained::Constrained for ByteSet {
|
1507 - | type Unconstrained = crate::unconstrained::byte_set_unconstrained::ByteSetUnconstrained;
|
1508 - | }
|
1509 - |
|
1510 1200 | #[allow(missing_docs)] // documentation missing in model
|
1511 1201 | ///
|
1512 1202 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
1513 - | /// [constraint traits]. Use [`StringSet::try_from`] to construct values of this type.
|
1203 + | /// [constraint traits]. Use [`MinShort::try_from`] to construct values of this type.
|
1514 1204 | ///
|
1515 1205 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1516 1206 | ///
|
1517 1207 | #[derive(
|
1518 1208 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1519 1209 | )]
|
1520 - | pub struct StringSet(pub(crate) ::std::vec::Vec<::std::string::String>);
|
1521 - | impl StringSet {
|
1522 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<::std::string::String>`].
|
1523 - | pub fn inner(&self) -> &::std::vec::Vec<::std::string::String> {
|
1210 + | pub struct MinShort(pub(crate) i16);
|
1211 + | impl MinShort {
|
1212 + | /// Returns an immutable reference to the underlying [`i16`].
|
1213 + | pub fn inner(&self) -> &i16 {
|
1524 1214 | &self.0
|
1525 1215 | }
|
1526 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<::std::string::String>`].
|
1527 - | pub fn into_inner(self) -> ::std::vec::Vec<::std::string::String> {
|
1216 + |
|
1217 + | /// Consumes the value, returning the underlying [`i16`].
|
1218 + | pub fn into_inner(self) -> i16 {
|
1528 1219 | self.0
|
1529 1220 | }
|
1221 + | }
|
1530 1222 |
|
1531 - | fn check_unique_items(
|
1532 - | items: ::std::vec::Vec<::std::string::String>,
|
1533 - | ) -> ::std::result::Result<
|
1534 - | ::std::vec::Vec<::std::string::String>,
|
1535 - | crate::model::string_set::ConstraintViolation,
|
1536 - | > {
|
1537 - | let mut seen = ::std::collections::HashMap::new();
|
1538 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
1539 - | for (idx, item) in items.iter().enumerate() {
|
1540 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
1541 - | duplicate_indices.push(prev_idx);
|
1542 - | }
|
1543 - | }
|
1223 + | impl crate::constrained::Constrained for MinShort {
|
1224 + | type Unconstrained = i16;
|
1225 + | }
|
1544 1226 |
|
1545 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
1546 - | for idx in &duplicate_indices {
|
1547 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
1548 - | last_duplicate_indices.push(prev_idx);
|
1227 + | impl ::std::convert::From<i16> for crate::constrained::MaybeConstrained<crate::model::MinShort> {
|
1228 + | fn from(value: i16) -> Self {
|
1229 + | Self::Unconstrained(value)
|
1549 1230 | }
|
1231 + | }
|
1232 + |
|
1233 + | impl ::std::fmt::Display for MinShort {
|
1234 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1235 + | self.0.fmt(f)
|
1550 1236 | }
|
1551 - | duplicate_indices.extend(last_duplicate_indices);
|
1237 + | }
|
1552 1238 |
|
1553 - | if !duplicate_indices.is_empty() {
|
1554 - | debug_assert!(duplicate_indices.len() >= 2);
|
1555 - | Err(crate::model::string_set::ConstraintViolation::UniqueItems {
|
1556 - | duplicate_indices,
|
1557 - | original: items,
|
1558 - | })
|
1239 + | impl ::std::convert::From<MinShort> for i16 {
|
1240 + | fn from(value: MinShort) -> Self {
|
1241 + | value.into_inner()
|
1242 + | }
|
1243 + | }
|
1244 + | impl MinShort {
|
1245 + | fn check_range(
|
1246 + | value: i16,
|
1247 + | ) -> ::std::result::Result<(), crate::model::min_short::ConstraintViolation> {
|
1248 + | if 2 <= value {
|
1249 + | Ok(())
|
1559 1250 | } else {
|
1560 - | Ok(items)
|
1251 + | Err(crate::model::min_short::ConstraintViolation::Range(value))
|
1561 1252 | }
|
1562 1253 | }
|
1563 1254 | }
|
1564 - | impl ::std::convert::TryFrom<::std::vec::Vec<::std::string::String>> for StringSet {
|
1565 - | type Error = crate::model::string_set::ConstraintViolation;
|
1255 + | impl ::std::convert::TryFrom<i16> for MinShort {
|
1256 + | type Error = crate::model::min_short::ConstraintViolation;
|
1566 1257 |
|
1567 - | /// Constructs a `StringSet` from an [`::std::vec::Vec<::std::string::String>`], failing when the provided value does not satisfy the modeled constraints.
|
1568 - | fn try_from(
|
1569 - | value: ::std::vec::Vec<::std::string::String>,
|
1570 - | ) -> ::std::result::Result<Self, Self::Error> {
|
1571 - | let value = Self::check_unique_items(value)?;
|
1258 + | /// Constructs a `MinShort` from an [`i16`], failing when the provided value does not satisfy the modeled constraints.
|
1259 + | fn try_from(value: i16) -> ::std::result::Result<Self, Self::Error> {
|
1260 + | Self::check_range(value)?;
|
1572 1261 |
|
1573 1262 | Ok(Self(value))
|
1574 1263 | }
|
1575 1264 | }
|
1576 1265 |
|
1577 - | impl ::std::convert::From<StringSet> for ::std::vec::Vec<::std::string::String> {
|
1578 - | fn from(value: StringSet) -> Self {
|
1579 - | value.into_inner()
|
1580 - | }
|
1581 - | }
|
1582 - | impl crate::constrained::Constrained for StringSet {
|
1583 - | type Unconstrained = crate::unconstrained::string_set_unconstrained::StringSetUnconstrained;
|
1584 - | }
|
1585 - |
|
1586 1266 | #[allow(missing_docs)] // documentation missing in model
|
1587 1267 | ///
|
1588 1268 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
1589 - | /// [constraint traits]. Use [`BooleanSet::try_from`] to construct values of this type.
|
1269 + | /// [constraint traits]. Use [`MaxShort::try_from`] to construct values of this type.
|
1590 1270 | ///
|
1591 1271 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1592 1272 | ///
|
1593 1273 | #[derive(
|
1594 1274 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1595 1275 | )]
|
1596 - | pub struct BooleanSet(pub(crate) ::std::vec::Vec<bool>);
|
1597 - | impl BooleanSet {
|
1598 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<bool>`].
|
1599 - | pub fn inner(&self) -> &::std::vec::Vec<bool> {
|
1276 + | pub struct MaxShort(pub(crate) i16);
|
1277 + | impl MaxShort {
|
1278 + | /// Returns an immutable reference to the underlying [`i16`].
|
1279 + | pub fn inner(&self) -> &i16 {
|
1600 1280 | &self.0
|
1601 1281 | }
|
1602 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<bool>`].
|
1603 - | pub fn into_inner(self) -> ::std::vec::Vec<bool> {
|
1604 - | self.0
|
1605 - | }
|
1606 1282 |
|
1607 - | fn check_unique_items(
|
1608 - | items: ::std::vec::Vec<bool>,
|
1609 - | ) -> ::std::result::Result<::std::vec::Vec<bool>, crate::model::boolean_set::ConstraintViolation>
|
1610 - | {
|
1611 - | let mut seen = ::std::collections::HashMap::new();
|
1612 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
1613 - | for (idx, item) in items.iter().enumerate() {
|
1614 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
1615 - | duplicate_indices.push(prev_idx);
|
1616 - | }
|
1283 + | /// Consumes the value, returning the underlying [`i16`].
|
1284 + | pub fn into_inner(self) -> i16 {
|
1285 + | self.0
|
1617 1286 | }
|
1287 + | }
|
1618 1288 |
|
1619 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
1620 - | for idx in &duplicate_indices {
|
1621 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
1622 - | last_duplicate_indices.push(prev_idx);
|
1623 - | }
|
1624 - | }
|
1625 - | duplicate_indices.extend(last_duplicate_indices);
|
1289 + | impl crate::constrained::Constrained for MaxShort {
|
1290 + | type Unconstrained = i16;
|
1291 + | }
|
1626 1292 |
|
1627 - | if !duplicate_indices.is_empty() {
|
1628 - | debug_assert!(duplicate_indices.len() >= 2);
|
1629 - | Err(
|
1630 - | crate::model::boolean_set::ConstraintViolation::UniqueItems {
|
1631 - | duplicate_indices,
|
1632 - | original: items,
|
1633 - | },
|
1634 - | )
|
1635 - | } else {
|
1636 - | Ok(items)
|
1637 - | }
|
1293 + | impl ::std::convert::From<i16> for crate::constrained::MaybeConstrained<crate::model::MaxShort> {
|
1294 + | fn from(value: i16) -> Self {
|
1295 + | Self::Unconstrained(value)
|
1638 1296 | }
|
1639 1297 | }
|
1640 - | impl ::std::convert::TryFrom<::std::vec::Vec<bool>> for BooleanSet {
|
1641 - | type Error = crate::model::boolean_set::ConstraintViolation;
|
1642 - |
|
1643 - | /// Constructs a `BooleanSet` from an [`::std::vec::Vec<bool>`], failing when the provided value does not satisfy the modeled constraints.
|
1644 - | fn try_from(value: ::std::vec::Vec<bool>) -> ::std::result::Result<Self, Self::Error> {
|
1645 - | let value = Self::check_unique_items(value)?;
|
1646 1298 |
|
1647 - | Ok(Self(value))
|
1299 + | impl ::std::fmt::Display for MaxShort {
|
1300 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1301 + | self.0.fmt(f)
|
1648 1302 | }
|
1649 1303 | }
|
1650 1304 |
|
1651 - | impl ::std::convert::From<BooleanSet> for ::std::vec::Vec<bool> {
|
1652 - | fn from(value: BooleanSet) -> Self {
|
1305 + | impl ::std::convert::From<MaxShort> for i16 {
|
1306 + | fn from(value: MaxShort) -> Self {
|
1653 1307 | value.into_inner()
|
1654 1308 | }
|
1655 1309 | }
|
1656 - | impl crate::constrained::Constrained for BooleanSet {
|
1657 - | type Unconstrained = crate::unconstrained::boolean_set_unconstrained::BooleanSetUnconstrained;
|
1658 - | }
|
1659 - |
|
1660 - | #[allow(missing_docs)] // documentation missing in model
|
1661 - | ///
|
1662 - | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
1663 - | /// [constraint traits]. Use [`BlobSet::try_from`] to construct values of this type.
|
1664 - | ///
|
1665 - | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1666 - | ///
|
1667 - | #[derive(
|
1668 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1669 - | )]
|
1670 - | pub struct BlobSet(pub(crate) ::std::vec::Vec<::aws_smithy_types::Blob>);
|
1671 - | impl BlobSet {
|
1672 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<::aws_smithy_types::Blob>`].
|
1673 - | pub fn inner(&self) -> &::std::vec::Vec<::aws_smithy_types::Blob> {
|
1674 - | &self.0
|
1675 - | }
|
1676 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<::aws_smithy_types::Blob>`].
|
1677 - | pub fn into_inner(self) -> ::std::vec::Vec<::aws_smithy_types::Blob> {
|
1678 - | self.0
|
1679 - | }
|
1680 - |
|
1681 - | fn check_unique_items(
|
1682 - | items: ::std::vec::Vec<::aws_smithy_types::Blob>,
|
1683 - | ) -> ::std::result::Result<
|
1684 - | ::std::vec::Vec<::aws_smithy_types::Blob>,
|
1685 - | crate::model::blob_set::ConstraintViolation,
|
1686 - | > {
|
1687 - | let mut seen = ::std::collections::HashMap::new();
|
1688 - | let mut duplicate_indices = ::std::vec::Vec::new();
|
1689 - | for (idx, item) in items.iter().enumerate() {
|
1690 - | if let Some(prev_idx) = seen.insert(item, idx) {
|
1691 - | duplicate_indices.push(prev_idx);
|
1692 - | }
|
1693 - | }
|
1694 - |
|
1695 - | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
1696 - | for idx in &duplicate_indices {
|
1697 - | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
1698 - | last_duplicate_indices.push(prev_idx);
|
1699 - | }
|
1700 - | }
|
1701 - | duplicate_indices.extend(last_duplicate_indices);
|
1702 - |
|
1703 - | if !duplicate_indices.is_empty() {
|
1704 - | debug_assert!(duplicate_indices.len() >= 2);
|
1705 - | Err(crate::model::blob_set::ConstraintViolation::UniqueItems {
|
1706 - | duplicate_indices,
|
1707 - | original: items,
|
1708 - | })
|
1310 + | impl MaxShort {
|
1311 + | fn check_range(
|
1312 + | value: i16,
|
1313 + | ) -> ::std::result::Result<(), crate::model::max_short::ConstraintViolation> {
|
1314 + | if value <= 8 {
|
1315 + | Ok(())
|
1709 1316 | } else {
|
1710 - | Ok(items)
|
1317 + | Err(crate::model::max_short::ConstraintViolation::Range(value))
|
1711 1318 | }
|
1712 1319 | }
|
1713 1320 | }
|
1714 - | impl ::std::convert::TryFrom<::std::vec::Vec<::aws_smithy_types::Blob>> for BlobSet {
|
1715 - | type Error = crate::model::blob_set::ConstraintViolation;
|
1321 + | impl ::std::convert::TryFrom<i16> for MaxShort {
|
1322 + | type Error = crate::model::max_short::ConstraintViolation;
|
1716 1323 |
|
1717 - | /// Constructs a `BlobSet` from an [`::std::vec::Vec<::aws_smithy_types::Blob>`], failing when the provided value does not satisfy the modeled constraints.
|
1718 - | fn try_from(
|
1719 - | value: ::std::vec::Vec<::aws_smithy_types::Blob>,
|
1720 - | ) -> ::std::result::Result<Self, Self::Error> {
|
1721 - | let value = Self::check_unique_items(value)?;
|
1324 + | /// Constructs a `MaxShort` from an [`i16`], failing when the provided value does not satisfy the modeled constraints.
|
1325 + | fn try_from(value: i16) -> ::std::result::Result<Self, Self::Error> {
|
1326 + | Self::check_range(value)?;
|
1722 1327 |
|
1723 1328 | Ok(Self(value))
|
1724 1329 | }
|
1725 1330 | }
|
1726 1331 |
|
1727 - | impl ::std::convert::From<BlobSet> for ::std::vec::Vec<::aws_smithy_types::Blob> {
|
1728 - | fn from(value: BlobSet) -> Self {
|
1729 - | value.into_inner()
|
1730 - | }
|
1731 - | }
|
1732 - | impl crate::constrained::Constrained for BlobSet {
|
1733 - | type Unconstrained = crate::unconstrained::blob_set_unconstrained::BlobSetUnconstrained;
|
1734 - | }
|
1735 - |
|
1736 1332 | #[allow(missing_docs)] // documentation missing in model
|
1737 1333 | ///
|
1738 1334 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
1739 - | /// [constraint traits]. Use [`MaxLong::try_from`] to construct values of this type.
|
1335 + | /// [constraint traits]. Use [`RangeInteger::try_from`] to construct values of this type.
|
1740 1336 | ///
|
1741 1337 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1742 1338 | ///
|
1743 1339 | #[derive(
|
1744 1340 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1745 1341 | )]
|
1746 - | pub struct MaxLong(pub(crate) i64);
|
1747 - | impl MaxLong {
|
1748 - | /// Returns an immutable reference to the underlying [`i64`].
|
1749 - | pub fn inner(&self) -> &i64 {
|
1342 + | pub struct RangeInteger(pub(crate) i32);
|
1343 + | impl RangeInteger {
|
1344 + | /// Returns an immutable reference to the underlying [`i32`].
|
1345 + | pub fn inner(&self) -> &i32 {
|
1750 1346 | &self.0
|
1751 1347 | }
|
1752 1348 |
|
1753 - | /// Consumes the value, returning the underlying [`i64`].
|
1754 - | pub fn into_inner(self) -> i64 {
|
1349 + | /// Consumes the value, returning the underlying [`i32`].
|
1350 + | pub fn into_inner(self) -> i32 {
|
1755 1351 | self.0
|
1756 1352 | }
|
1757 1353 | }
|
1758 1354 |
|
1759 - | impl crate::constrained::Constrained for MaxLong {
|
1760 - | type Unconstrained = i64;
|
1355 + | impl crate::constrained::Constrained for RangeInteger {
|
1356 + | type Unconstrained = i32;
|
1761 1357 | }
|
1762 1358 |
|
1763 - | impl ::std::convert::From<i64> for crate::constrained::MaybeConstrained<crate::model::MaxLong> {
|
1764 - | fn from(value: i64) -> Self {
|
1359 + | impl ::std::convert::From<i32>
|
1360 + | for crate::constrained::MaybeConstrained<crate::model::RangeInteger>
|
1361 + | {
|
1362 + | fn from(value: i32) -> Self {
|
1765 1363 | Self::Unconstrained(value)
|
1766 1364 | }
|
1767 1365 | }
|
1768 1366 |
|
1769 - | impl ::std::fmt::Display for MaxLong {
|
1367 + | impl ::std::fmt::Display for RangeInteger {
|
1770 1368 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1771 1369 | self.0.fmt(f)
|
1772 1370 | }
|
1773 1371 | }
|
1774 1372 |
|
1775 - | impl ::std::convert::From<MaxLong> for i64 {
|
1776 - | fn from(value: MaxLong) -> Self {
|
1373 + | impl ::std::convert::From<RangeInteger> for i32 {
|
1374 + | fn from(value: RangeInteger) -> Self {
|
1777 1375 | value.into_inner()
|
1778 1376 | }
|
1779 1377 | }
|
1780 - | impl MaxLong {
|
1378 + | impl RangeInteger {
|
1781 1379 | fn check_range(
|
1782 - | value: i64,
|
1783 - | ) -> ::std::result::Result<(), crate::model::max_long::ConstraintViolation> {
|
1784 - | if value <= 8 {
|
1380 + | value: i32,
|
1381 + | ) -> ::std::result::Result<(), crate::model::range_integer::ConstraintViolation> {
|
1382 + | if (2..=8).contains(&value) {
|
1785 1383 | Ok(())
|
1786 1384 | } else {
|
1787 - | Err(crate::model::max_long::ConstraintViolation::Range(value))
|
1385 + | Err(crate::model::range_integer::ConstraintViolation::Range(
|
1386 + | value,
|
1387 + | ))
|
1788 1388 | }
|
1789 1389 | }
|
1790 1390 | }
|
1791 - | impl ::std::convert::TryFrom<i64> for MaxLong {
|
1792 - | type Error = crate::model::max_long::ConstraintViolation;
|
1391 + | impl ::std::convert::TryFrom<i32> for RangeInteger {
|
1392 + | type Error = crate::model::range_integer::ConstraintViolation;
|
1793 1393 |
|
1794 - | /// Constructs a `MaxLong` from an [`i64`], failing when the provided value does not satisfy the modeled constraints.
|
1795 - | fn try_from(value: i64) -> ::std::result::Result<Self, Self::Error> {
|
1394 + | /// Constructs a `RangeInteger` from an [`i32`], failing when the provided value does not satisfy the modeled constraints.
|
1395 + | fn try_from(value: i32) -> ::std::result::Result<Self, Self::Error> {
|
1796 1396 | Self::check_range(value)?;
|
1797 1397 |
|
1798 1398 | Ok(Self(value))
|
1799 1399 | }
|
1800 1400 | }
|
1801 1401 |
|
1802 1402 | #[allow(missing_docs)] // documentation missing in model
|
1803 1403 | ///
|
1804 1404 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
1805 - | /// [constraint traits]. Use [`MinLong::try_from`] to construct values of this type.
|
1405 + | /// [constraint traits]. Use [`MinInteger::try_from`] to construct values of this type.
|
1806 1406 | ///
|
1807 1407 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1808 1408 | ///
|
1809 1409 | #[derive(
|
1810 1410 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1811 1411 | )]
|
1812 - | pub struct MinLong(pub(crate) i64);
|
1813 - | impl MinLong {
|
1814 - | /// Returns an immutable reference to the underlying [`i64`].
|
1815 - | pub fn inner(&self) -> &i64 {
|
1412 + | pub struct MinInteger(pub(crate) i32);
|
1413 + | impl MinInteger {
|
1414 + | /// Returns an immutable reference to the underlying [`i32`].
|
1415 + | pub fn inner(&self) -> &i32 {
|
1816 1416 | &self.0
|
1817 1417 | }
|
1818 1418 |
|
1819 - | /// Consumes the value, returning the underlying [`i64`].
|
1820 - | pub fn into_inner(self) -> i64 {
|
1419 + | /// Consumes the value, returning the underlying [`i32`].
|
1420 + | pub fn into_inner(self) -> i32 {
|
1821 1421 | self.0
|
1822 1422 | }
|
1823 1423 | }
|
1824 1424 |
|
1825 - | impl crate::constrained::Constrained for MinLong {
|
1826 - | type Unconstrained = i64;
|
1425 + | impl crate::constrained::Constrained for MinInteger {
|
1426 + | type Unconstrained = i32;
|
1827 1427 | }
|
1828 1428 |
|
1829 - | impl ::std::convert::From<i64> for crate::constrained::MaybeConstrained<crate::model::MinLong> {
|
1830 - | fn from(value: i64) -> Self {
|
1429 + | impl ::std::convert::From<i32> for crate::constrained::MaybeConstrained<crate::model::MinInteger> {
|
1430 + | fn from(value: i32) -> Self {
|
1831 1431 | Self::Unconstrained(value)
|
1832 1432 | }
|
1833 1433 | }
|
1834 1434 |
|
1835 - | impl ::std::fmt::Display for MinLong {
|
1435 + | impl ::std::fmt::Display for MinInteger {
|
1836 1436 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1837 1437 | self.0.fmt(f)
|
1838 1438 | }
|
1839 1439 | }
|
1840 1440 |
|
1841 - | impl ::std::convert::From<MinLong> for i64 {
|
1842 - | fn from(value: MinLong) -> Self {
|
1441 + | impl ::std::convert::From<MinInteger> for i32 {
|
1442 + | fn from(value: MinInteger) -> Self {
|
1843 1443 | value.into_inner()
|
1844 1444 | }
|
1845 1445 | }
|
1846 - | impl MinLong {
|
1446 + | impl MinInteger {
|
1847 1447 | fn check_range(
|
1848 - | value: i64,
|
1849 - | ) -> ::std::result::Result<(), crate::model::min_long::ConstraintViolation> {
|
1448 + | value: i32,
|
1449 + | ) -> ::std::result::Result<(), crate::model::min_integer::ConstraintViolation> {
|
1850 1450 | if 2 <= value {
|
1851 1451 | Ok(())
|
1852 1452 | } else {
|
1853 - | Err(crate::model::min_long::ConstraintViolation::Range(value))
|
1854 - | }
|
1855 - | }
|
1856 - | }
|
1857 - | impl ::std::convert::TryFrom<i64> for MinLong {
|
1858 - | type Error = crate::model::min_long::ConstraintViolation;
|
1859 - |
|
1860 - | /// Constructs a `MinLong` from an [`i64`], failing when the provided value does not satisfy the modeled constraints.
|
1861 - | fn try_from(value: i64) -> ::std::result::Result<Self, Self::Error> {
|
1862 - | Self::check_range(value)?;
|
1863 - |
|
1864 - | Ok(Self(value))
|
1865 - | }
|
1866 - | }
|
1867 - |
|
1868 - | #[allow(missing_docs)] // documentation missing in model
|
1869 - | ///
|
1870 - | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
1871 - | /// [constraint traits]. Use [`RangeLong::try_from`] to construct values of this type.
|
1872 - | ///
|
1873 - | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1874 - | ///
|
1875 - | #[derive(
|
1876 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1877 - | )]
|
1878 - | pub struct RangeLong(pub(crate) i64);
|
1879 - | impl RangeLong {
|
1880 - | /// Returns an immutable reference to the underlying [`i64`].
|
1881 - | pub fn inner(&self) -> &i64 {
|
1882 - | &self.0
|
1883 - | }
|
1884 - |
|
1885 - | /// Consumes the value, returning the underlying [`i64`].
|
1886 - | pub fn into_inner(self) -> i64 {
|
1887 - | self.0
|
1888 - | }
|
1889 - | }
|
1890 - |
|
1891 - | impl crate::constrained::Constrained for RangeLong {
|
1892 - | type Unconstrained = i64;
|
1893 - | }
|
1894 - |
|
1895 - | impl ::std::convert::From<i64> for crate::constrained::MaybeConstrained<crate::model::RangeLong> {
|
1896 - | fn from(value: i64) -> Self {
|
1897 - | Self::Unconstrained(value)
|
1898 - | }
|
1899 - | }
|
1900 - |
|
1901 - | impl ::std::fmt::Display for RangeLong {
|
1902 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1903 - | self.0.fmt(f)
|
1904 - | }
|
1905 - | }
|
1906 - |
|
1907 - | impl ::std::convert::From<RangeLong> for i64 {
|
1908 - | fn from(value: RangeLong) -> Self {
|
1909 - | value.into_inner()
|
1910 - | }
|
1911 - | }
|
1912 - | impl RangeLong {
|
1913 - | fn check_range(
|
1914 - | value: i64,
|
1915 - | ) -> ::std::result::Result<(), crate::model::range_long::ConstraintViolation> {
|
1916 - | if (2..=8).contains(&value) {
|
1917 - | Ok(())
|
1918 - | } else {
|
1919 - | Err(crate::model::range_long::ConstraintViolation::Range(value))
|
1453 + | Err(crate::model::min_integer::ConstraintViolation::Range(value))
|
1920 1454 | }
|
1921 1455 | }
|
1922 1456 | }
|
1923 - | impl ::std::convert::TryFrom<i64> for RangeLong {
|
1924 - | type Error = crate::model::range_long::ConstraintViolation;
|
1457 + | impl ::std::convert::TryFrom<i32> for MinInteger {
|
1458 + | type Error = crate::model::min_integer::ConstraintViolation;
|
1925 1459 |
|
1926 - | /// Constructs a `RangeLong` from an [`i64`], failing when the provided value does not satisfy the modeled constraints.
|
1927 - | fn try_from(value: i64) -> ::std::result::Result<Self, Self::Error> {
|
1460 + | /// Constructs a `MinInteger` from an [`i32`], failing when the provided value does not satisfy the modeled constraints.
|
1461 + | fn try_from(value: i32) -> ::std::result::Result<Self, Self::Error> {
|
1928 1462 | Self::check_range(value)?;
|
1929 1463 |
|
1930 1464 | Ok(Self(value))
|
1931 1465 | }
|
1932 1466 | }
|
1933 1467 |
|
1934 1468 | #[allow(missing_docs)] // documentation missing in model
|
1935 1469 | ///
|
1936 1470 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
1937 1471 | /// [constraint traits]. Use [`MaxInteger::try_from`] to construct values of this type.
|
1993 1527 | fn try_from(value: i32) -> ::std::result::Result<Self, Self::Error> {
|
1994 1528 | Self::check_range(value)?;
|
1995 1529 |
|
1996 1530 | Ok(Self(value))
|
1997 1531 | }
|
1998 1532 | }
|
1999 1533 |
|
2000 1534 | #[allow(missing_docs)] // documentation missing in model
|
2001 1535 | ///
|
2002 1536 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2003 - | /// [constraint traits]. Use [`MinInteger::try_from`] to construct values of this type.
|
1537 + | /// [constraint traits]. Use [`RangeLong::try_from`] to construct values of this type.
|
2004 1538 | ///
|
2005 1539 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2006 1540 | ///
|
2007 1541 | #[derive(
|
2008 1542 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2009 1543 | )]
|
2010 - | pub struct MinInteger(pub(crate) i32);
|
2011 - | impl MinInteger {
|
2012 - | /// Returns an immutable reference to the underlying [`i32`].
|
2013 - | pub fn inner(&self) -> &i32 {
|
1544 + | pub struct RangeLong(pub(crate) i64);
|
1545 + | impl RangeLong {
|
1546 + | /// Returns an immutable reference to the underlying [`i64`].
|
1547 + | pub fn inner(&self) -> &i64 {
|
2014 1548 | &self.0
|
2015 1549 | }
|
2016 1550 |
|
2017 - | /// Consumes the value, returning the underlying [`i32`].
|
2018 - | pub fn into_inner(self) -> i32 {
|
1551 + | /// Consumes the value, returning the underlying [`i64`].
|
1552 + | pub fn into_inner(self) -> i64 {
|
2019 1553 | self.0
|
2020 1554 | }
|
2021 1555 | }
|
2022 1556 |
|
2023 - | impl crate::constrained::Constrained for MinInteger {
|
2024 - | type Unconstrained = i32;
|
1557 + | impl crate::constrained::Constrained for RangeLong {
|
1558 + | type Unconstrained = i64;
|
2025 1559 | }
|
2026 1560 |
|
2027 - | impl ::std::convert::From<i32> for crate::constrained::MaybeConstrained<crate::model::MinInteger> {
|
2028 - | fn from(value: i32) -> Self {
|
1561 + | impl ::std::convert::From<i64> for crate::constrained::MaybeConstrained<crate::model::RangeLong> {
|
1562 + | fn from(value: i64) -> Self {
|
2029 1563 | Self::Unconstrained(value)
|
2030 1564 | }
|
2031 1565 | }
|
2032 1566 |
|
2033 - | impl ::std::fmt::Display for MinInteger {
|
1567 + | impl ::std::fmt::Display for RangeLong {
|
2034 1568 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2035 1569 | self.0.fmt(f)
|
2036 1570 | }
|
2037 1571 | }
|
2038 1572 |
|
2039 - | impl ::std::convert::From<MinInteger> for i32 {
|
2040 - | fn from(value: MinInteger) -> Self {
|
1573 + | impl ::std::convert::From<RangeLong> for i64 {
|
1574 + | fn from(value: RangeLong) -> Self {
|
2041 1575 | value.into_inner()
|
2042 1576 | }
|
2043 1577 | }
|
2044 - | impl MinInteger {
|
1578 + | impl RangeLong {
|
2045 1579 | fn check_range(
|
2046 - | value: i32,
|
2047 - | ) -> ::std::result::Result<(), crate::model::min_integer::ConstraintViolation> {
|
2048 - | if 2 <= value {
|
1580 + | value: i64,
|
1581 + | ) -> ::std::result::Result<(), crate::model::range_long::ConstraintViolation> {
|
1582 + | if (2..=8).contains(&value) {
|
2049 1583 | Ok(())
|
2050 1584 | } else {
|
2051 - | Err(crate::model::min_integer::ConstraintViolation::Range(value))
|
1585 + | Err(crate::model::range_long::ConstraintViolation::Range(value))
|
2052 1586 | }
|
2053 1587 | }
|
2054 1588 | }
|
2055 - | impl ::std::convert::TryFrom<i32> for MinInteger {
|
2056 - | type Error = crate::model::min_integer::ConstraintViolation;
|
1589 + | impl ::std::convert::TryFrom<i64> for RangeLong {
|
1590 + | type Error = crate::model::range_long::ConstraintViolation;
|
2057 1591 |
|
2058 - | /// Constructs a `MinInteger` from an [`i32`], failing when the provided value does not satisfy the modeled constraints.
|
2059 - | fn try_from(value: i32) -> ::std::result::Result<Self, Self::Error> {
|
1592 + | /// Constructs a `RangeLong` from an [`i64`], failing when the provided value does not satisfy the modeled constraints.
|
1593 + | fn try_from(value: i64) -> ::std::result::Result<Self, Self::Error> {
|
2060 1594 | Self::check_range(value)?;
|
2061 1595 |
|
2062 1596 | Ok(Self(value))
|
2063 1597 | }
|
2064 1598 | }
|
2065 1599 |
|
2066 1600 | #[allow(missing_docs)] // documentation missing in model
|
2067 1601 | ///
|
2068 1602 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2069 - | /// [constraint traits]. Use [`RangeInteger::try_from`] to construct values of this type.
|
1603 + | /// [constraint traits]. Use [`MinLong::try_from`] to construct values of this type.
|
2070 1604 | ///
|
2071 1605 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2072 1606 | ///
|
2073 1607 | #[derive(
|
2074 1608 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2075 1609 | )]
|
2076 - | pub struct RangeInteger(pub(crate) i32);
|
2077 - | impl RangeInteger {
|
2078 - | /// Returns an immutable reference to the underlying [`i32`].
|
2079 - | pub fn inner(&self) -> &i32 {
|
1610 + | pub struct MinLong(pub(crate) i64);
|
1611 + | impl MinLong {
|
1612 + | /// Returns an immutable reference to the underlying [`i64`].
|
1613 + | pub fn inner(&self) -> &i64 {
|
2080 1614 | &self.0
|
2081 1615 | }
|
2082 1616 |
|
2083 - | /// Consumes the value, returning the underlying [`i32`].
|
2084 - | pub fn into_inner(self) -> i32 {
|
1617 + | /// Consumes the value, returning the underlying [`i64`].
|
1618 + | pub fn into_inner(self) -> i64 {
|
2085 1619 | self.0
|
2086 1620 | }
|
2087 1621 | }
|
2088 1622 |
|
2089 - | impl crate::constrained::Constrained for RangeInteger {
|
2090 - | type Unconstrained = i32;
|
1623 + | impl crate::constrained::Constrained for MinLong {
|
1624 + | type Unconstrained = i64;
|
2091 1625 | }
|
2092 1626 |
|
2093 - | impl ::std::convert::From<i32>
|
2094 - | for crate::constrained::MaybeConstrained<crate::model::RangeInteger>
|
2095 - | {
|
2096 - | fn from(value: i32) -> Self {
|
1627 + | impl ::std::convert::From<i64> for crate::constrained::MaybeConstrained<crate::model::MinLong> {
|
1628 + | fn from(value: i64) -> Self {
|
2097 1629 | Self::Unconstrained(value)
|
2098 1630 | }
|
2099 1631 | }
|
2100 1632 |
|
2101 - | impl ::std::fmt::Display for RangeInteger {
|
1633 + | impl ::std::fmt::Display for MinLong {
|
2102 1634 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2103 1635 | self.0.fmt(f)
|
2104 1636 | }
|
2105 1637 | }
|
2106 1638 |
|
2107 - | impl ::std::convert::From<RangeInteger> for i32 {
|
2108 - | fn from(value: RangeInteger) -> Self {
|
1639 + | impl ::std::convert::From<MinLong> for i64 {
|
1640 + | fn from(value: MinLong) -> Self {
|
2109 1641 | value.into_inner()
|
2110 1642 | }
|
2111 1643 | }
|
2112 - | impl RangeInteger {
|
1644 + | impl MinLong {
|
2113 1645 | fn check_range(
|
2114 - | value: i32,
|
2115 - | ) -> ::std::result::Result<(), crate::model::range_integer::ConstraintViolation> {
|
2116 - | if (2..=8).contains(&value) {
|
1646 + | value: i64,
|
1647 + | ) -> ::std::result::Result<(), crate::model::min_long::ConstraintViolation> {
|
1648 + | if 2 <= value {
|
2117 1649 | Ok(())
|
2118 1650 | } else {
|
2119 - | Err(crate::model::range_integer::ConstraintViolation::Range(
|
2120 - | value,
|
2121 - | ))
|
1651 + | Err(crate::model::min_long::ConstraintViolation::Range(value))
|
2122 1652 | }
|
2123 1653 | }
|
2124 1654 | }
|
2125 - | impl ::std::convert::TryFrom<i32> for RangeInteger {
|
2126 - | type Error = crate::model::range_integer::ConstraintViolation;
|
1655 + | impl ::std::convert::TryFrom<i64> for MinLong {
|
1656 + | type Error = crate::model::min_long::ConstraintViolation;
|
2127 1657 |
|
2128 - | /// Constructs a `RangeInteger` from an [`i32`], failing when the provided value does not satisfy the modeled constraints.
|
2129 - | fn try_from(value: i32) -> ::std::result::Result<Self, Self::Error> {
|
1658 + | /// Constructs a `MinLong` from an [`i64`], failing when the provided value does not satisfy the modeled constraints.
|
1659 + | fn try_from(value: i64) -> ::std::result::Result<Self, Self::Error> {
|
2130 1660 | Self::check_range(value)?;
|
2131 1661 |
|
2132 1662 | Ok(Self(value))
|
2133 1663 | }
|
2134 1664 | }
|
2135 1665 |
|
2136 1666 | #[allow(missing_docs)] // documentation missing in model
|
2137 1667 | ///
|
2138 1668 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2139 - | /// [constraint traits]. Use [`MaxShort::try_from`] to construct values of this type.
|
1669 + | /// [constraint traits]. Use [`MaxLong::try_from`] to construct values of this type.
|
2140 1670 | ///
|
2141 1671 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2142 1672 | ///
|
2143 1673 | #[derive(
|
2144 1674 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2145 1675 | )]
|
2146 - | pub struct MaxShort(pub(crate) i16);
|
2147 - | impl MaxShort {
|
2148 - | /// Returns an immutable reference to the underlying [`i16`].
|
2149 - | pub fn inner(&self) -> &i16 {
|
1676 + | pub struct MaxLong(pub(crate) i64);
|
1677 + | impl MaxLong {
|
1678 + | /// Returns an immutable reference to the underlying [`i64`].
|
1679 + | pub fn inner(&self) -> &i64 {
|
2150 1680 | &self.0
|
2151 1681 | }
|
2152 1682 |
|
2153 - | /// Consumes the value, returning the underlying [`i16`].
|
2154 - | pub fn into_inner(self) -> i16 {
|
1683 + | /// Consumes the value, returning the underlying [`i64`].
|
1684 + | pub fn into_inner(self) -> i64 {
|
2155 1685 | self.0
|
2156 1686 | }
|
2157 1687 | }
|
2158 1688 |
|
2159 - | impl crate::constrained::Constrained for MaxShort {
|
2160 - | type Unconstrained = i16;
|
1689 + | impl crate::constrained::Constrained for MaxLong {
|
1690 + | type Unconstrained = i64;
|
2161 1691 | }
|
2162 1692 |
|
2163 - | impl ::std::convert::From<i16> for crate::constrained::MaybeConstrained<crate::model::MaxShort> {
|
2164 - | fn from(value: i16) -> Self {
|
1693 + | impl ::std::convert::From<i64> for crate::constrained::MaybeConstrained<crate::model::MaxLong> {
|
1694 + | fn from(value: i64) -> Self {
|
2165 1695 | Self::Unconstrained(value)
|
2166 1696 | }
|
2167 1697 | }
|
2168 1698 |
|
2169 - | impl ::std::fmt::Display for MaxShort {
|
1699 + | impl ::std::fmt::Display for MaxLong {
|
2170 1700 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2171 1701 | self.0.fmt(f)
|
2172 1702 | }
|
2173 1703 | }
|
2174 1704 |
|
2175 - | impl ::std::convert::From<MaxShort> for i16 {
|
2176 - | fn from(value: MaxShort) -> Self {
|
1705 + | impl ::std::convert::From<MaxLong> for i64 {
|
1706 + | fn from(value: MaxLong) -> Self {
|
2177 1707 | value.into_inner()
|
2178 1708 | }
|
2179 1709 | }
|
2180 - | impl MaxShort {
|
1710 + | impl MaxLong {
|
2181 1711 | fn check_range(
|
2182 - | value: i16,
|
2183 - | ) -> ::std::result::Result<(), crate::model::max_short::ConstraintViolation> {
|
1712 + | value: i64,
|
1713 + | ) -> ::std::result::Result<(), crate::model::max_long::ConstraintViolation> {
|
2184 1714 | if value <= 8 {
|
2185 1715 | Ok(())
|
2186 1716 | } else {
|
2187 - | Err(crate::model::max_short::ConstraintViolation::Range(value))
|
1717 + | Err(crate::model::max_long::ConstraintViolation::Range(value))
|
2188 1718 | }
|
2189 1719 | }
|
2190 1720 | }
|
2191 - | impl ::std::convert::TryFrom<i16> for MaxShort {
|
2192 - | type Error = crate::model::max_short::ConstraintViolation;
|
1721 + | impl ::std::convert::TryFrom<i64> for MaxLong {
|
1722 + | type Error = crate::model::max_long::ConstraintViolation;
|
2193 1723 |
|
2194 - | /// Constructs a `MaxShort` from an [`i16`], failing when the provided value does not satisfy the modeled constraints.
|
2195 - | fn try_from(value: i16) -> ::std::result::Result<Self, Self::Error> {
|
1724 + | /// Constructs a `MaxLong` from an [`i64`], failing when the provided value does not satisfy the modeled constraints.
|
1725 + | fn try_from(value: i64) -> ::std::result::Result<Self, Self::Error> {
|
2196 1726 | Self::check_range(value)?;
|
2197 1727 |
|
2198 1728 | Ok(Self(value))
|
2199 1729 | }
|
2200 1730 | }
|
2201 1731 |
|
2202 1732 | #[allow(missing_docs)] // documentation missing in model
|
2203 1733 | ///
|
2204 1734 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2205 - | /// [constraint traits]. Use [`MinShort::try_from`] to construct values of this type.
|
1735 + | /// [constraint traits]. Use [`BlobSet::try_from`] to construct values of this type.
|
2206 1736 | ///
|
2207 1737 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2208 1738 | ///
|
2209 1739 | #[derive(
|
2210 1740 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2211 1741 | )]
|
2212 - | pub struct MinShort(pub(crate) i16);
|
2213 - | impl MinShort {
|
2214 - | /// Returns an immutable reference to the underlying [`i16`].
|
2215 - | pub fn inner(&self) -> &i16 {
|
1742 + | pub struct BlobSet(pub(crate) ::std::vec::Vec<::aws_smithy_types::Blob>);
|
1743 + | impl BlobSet {
|
1744 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<::aws_smithy_types::Blob>`].
|
1745 + | pub fn inner(&self) -> &::std::vec::Vec<::aws_smithy_types::Blob> {
|
2216 1746 | &self.0
|
2217 1747 | }
|
2218 - |
|
2219 - | /// Consumes the value, returning the underlying [`i16`].
|
2220 - | pub fn into_inner(self) -> i16 {
|
1748 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<::aws_smithy_types::Blob>`].
|
1749 + | pub fn into_inner(self) -> ::std::vec::Vec<::aws_smithy_types::Blob> {
|
2221 1750 | self.0
|
2222 1751 | }
|
2223 - | }
|
2224 1752 |
|
2225 - | impl crate::constrained::Constrained for MinShort {
|
2226 - | type Unconstrained = i16;
|
2227 - | }
|
2228 - |
|
2229 - | impl ::std::convert::From<i16> for crate::constrained::MaybeConstrained<crate::model::MinShort> {
|
2230 - | fn from(value: i16) -> Self {
|
2231 - | Self::Unconstrained(value)
|
2232 - | }
|
2233 - | }
|
2234 - |
|
2235 - | impl ::std::fmt::Display for MinShort {
|
2236 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2237 - | self.0.fmt(f)
|
1753 + | fn check_unique_items(
|
1754 + | items: ::std::vec::Vec<::aws_smithy_types::Blob>,
|
1755 + | ) -> ::std::result::Result<
|
1756 + | ::std::vec::Vec<::aws_smithy_types::Blob>,
|
1757 + | crate::model::blob_set::ConstraintViolation,
|
1758 + | > {
|
1759 + | let mut seen = ::std::collections::HashMap::new();
|
1760 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
1761 + | for (idx, item) in items.iter().enumerate() {
|
1762 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
1763 + | duplicate_indices.push(prev_idx);
|
1764 + | }
|
2238 1765 | }
|
2239 - | }
|
2240 1766 |
|
2241 - | impl ::std::convert::From<MinShort> for i16 {
|
2242 - | fn from(value: MinShort) -> Self {
|
2243 - | value.into_inner()
|
1767 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
1768 + | for idx in &duplicate_indices {
|
1769 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
1770 + | last_duplicate_indices.push(prev_idx);
|
2244 1771 | }
|
2245 - | }
|
2246 - | impl MinShort {
|
2247 - | fn check_range(
|
2248 - | value: i16,
|
2249 - | ) -> ::std::result::Result<(), crate::model::min_short::ConstraintViolation> {
|
2250 - | if 2 <= value {
|
2251 - | Ok(())
|
1772 + | }
|
1773 + | duplicate_indices.extend(last_duplicate_indices);
|
1774 + |
|
1775 + | if !duplicate_indices.is_empty() {
|
1776 + | debug_assert!(duplicate_indices.len() >= 2);
|
1777 + | Err(crate::model::blob_set::ConstraintViolation::UniqueItems {
|
1778 + | duplicate_indices,
|
1779 + | original: items,
|
1780 + | })
|
2252 1781 | } else {
|
2253 - | Err(crate::model::min_short::ConstraintViolation::Range(value))
|
1782 + | Ok(items)
|
2254 1783 | }
|
2255 1784 | }
|
2256 1785 | }
|
2257 - | impl ::std::convert::TryFrom<i16> for MinShort {
|
2258 - | type Error = crate::model::min_short::ConstraintViolation;
|
1786 + | impl ::std::convert::TryFrom<::std::vec::Vec<::aws_smithy_types::Blob>> for BlobSet {
|
1787 + | type Error = crate::model::blob_set::ConstraintViolation;
|
2259 1788 |
|
2260 - | /// Constructs a `MinShort` from an [`i16`], failing when the provided value does not satisfy the modeled constraints.
|
2261 - | fn try_from(value: i16) -> ::std::result::Result<Self, Self::Error> {
|
2262 - | Self::check_range(value)?;
|
1789 + | /// Constructs a `BlobSet` from an [`::std::vec::Vec<::aws_smithy_types::Blob>`], failing when the provided value does not satisfy the modeled constraints.
|
1790 + | fn try_from(
|
1791 + | value: ::std::vec::Vec<::aws_smithy_types::Blob>,
|
1792 + | ) -> ::std::result::Result<Self, Self::Error> {
|
1793 + | let value = Self::check_unique_items(value)?;
|
2263 1794 |
|
2264 1795 | Ok(Self(value))
|
2265 1796 | }
|
2266 1797 | }
|
2267 1798 |
|
1799 + | impl ::std::convert::From<BlobSet> for ::std::vec::Vec<::aws_smithy_types::Blob> {
|
1800 + | fn from(value: BlobSet) -> Self {
|
1801 + | value.into_inner()
|
1802 + | }
|
1803 + | }
|
1804 + | impl crate::constrained::Constrained for BlobSet {
|
1805 + | type Unconstrained = crate::unconstrained::blob_set_unconstrained::BlobSetUnconstrained;
|
1806 + | }
|
1807 + |
|
2268 1808 | #[allow(missing_docs)] // documentation missing in model
|
2269 1809 | ///
|
2270 1810 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2271 - | /// [constraint traits]. Use [`RangeShort::try_from`] to construct values of this type.
|
1811 + | /// [constraint traits]. Use [`BooleanSet::try_from`] to construct values of this type.
|
2272 1812 | ///
|
2273 1813 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2274 1814 | ///
|
2275 1815 | #[derive(
|
2276 1816 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2277 1817 | )]
|
2278 - | pub struct RangeShort(pub(crate) i16);
|
2279 - | impl RangeShort {
|
2280 - | /// Returns an immutable reference to the underlying [`i16`].
|
2281 - | pub fn inner(&self) -> &i16 {
|
1818 + | pub struct BooleanSet(pub(crate) ::std::vec::Vec<bool>);
|
1819 + | impl BooleanSet {
|
1820 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<bool>`].
|
1821 + | pub fn inner(&self) -> &::std::vec::Vec<bool> {
|
2282 1822 | &self.0
|
2283 1823 | }
|
2284 - |
|
2285 - | /// Consumes the value, returning the underlying [`i16`].
|
2286 - | pub fn into_inner(self) -> i16 {
|
1824 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<bool>`].
|
1825 + | pub fn into_inner(self) -> ::std::vec::Vec<bool> {
|
2287 1826 | self.0
|
2288 1827 | }
|
2289 - | }
|
2290 1828 |
|
2291 - | impl crate::constrained::Constrained for RangeShort {
|
2292 - | type Unconstrained = i16;
|
2293 - | }
|
2294 - |
|
2295 - | impl ::std::convert::From<i16> for crate::constrained::MaybeConstrained<crate::model::RangeShort> {
|
2296 - | fn from(value: i16) -> Self {
|
2297 - | Self::Unconstrained(value)
|
1829 + | fn check_unique_items(
|
1830 + | items: ::std::vec::Vec<bool>,
|
1831 + | ) -> ::std::result::Result<::std::vec::Vec<bool>, crate::model::boolean_set::ConstraintViolation>
|
1832 + | {
|
1833 + | let mut seen = ::std::collections::HashMap::new();
|
1834 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
1835 + | for (idx, item) in items.iter().enumerate() {
|
1836 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
1837 + | duplicate_indices.push(prev_idx);
|
2298 1838 | }
|
2299 - | }
|
2300 - |
|
2301 - | impl ::std::fmt::Display for RangeShort {
|
2302 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2303 - | self.0.fmt(f)
|
2304 1839 | }
|
2305 - | }
|
2306 1840 |
|
2307 - | impl ::std::convert::From<RangeShort> for i16 {
|
2308 - | fn from(value: RangeShort) -> Self {
|
2309 - | value.into_inner()
|
1841 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
1842 + | for idx in &duplicate_indices {
|
1843 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
1844 + | last_duplicate_indices.push(prev_idx);
|
2310 1845 | }
|
2311 - | }
|
2312 - | impl RangeShort {
|
2313 - | fn check_range(
|
2314 - | value: i16,
|
2315 - | ) -> ::std::result::Result<(), crate::model::range_short::ConstraintViolation> {
|
2316 - | if (2..=8).contains(&value) {
|
2317 - | Ok(())
|
1846 + | }
|
1847 + | duplicate_indices.extend(last_duplicate_indices);
|
1848 + |
|
1849 + | if !duplicate_indices.is_empty() {
|
1850 + | debug_assert!(duplicate_indices.len() >= 2);
|
1851 + | Err(
|
1852 + | crate::model::boolean_set::ConstraintViolation::UniqueItems {
|
1853 + | duplicate_indices,
|
1854 + | original: items,
|
1855 + | },
|
1856 + | )
|
2318 1857 | } else {
|
2319 - | Err(crate::model::range_short::ConstraintViolation::Range(value))
|
1858 + | Ok(items)
|
2320 1859 | }
|
2321 1860 | }
|
2322 1861 | }
|
2323 - | impl ::std::convert::TryFrom<i16> for RangeShort {
|
2324 - | type Error = crate::model::range_short::ConstraintViolation;
|
1862 + | impl ::std::convert::TryFrom<::std::vec::Vec<bool>> for BooleanSet {
|
1863 + | type Error = crate::model::boolean_set::ConstraintViolation;
|
2325 1864 |
|
2326 - | /// Constructs a `RangeShort` from an [`i16`], failing when the provided value does not satisfy the modeled constraints.
|
2327 - | fn try_from(value: i16) -> ::std::result::Result<Self, Self::Error> {
|
2328 - | Self::check_range(value)?;
|
1865 + | /// Constructs a `BooleanSet` from an [`::std::vec::Vec<bool>`], failing when the provided value does not satisfy the modeled constraints.
|
1866 + | fn try_from(value: ::std::vec::Vec<bool>) -> ::std::result::Result<Self, Self::Error> {
|
1867 + | let value = Self::check_unique_items(value)?;
|
2329 1868 |
|
2330 1869 | Ok(Self(value))
|
2331 1870 | }
|
2332 1871 | }
|
2333 1872 |
|
1873 + | impl ::std::convert::From<BooleanSet> for ::std::vec::Vec<bool> {
|
1874 + | fn from(value: BooleanSet) -> Self {
|
1875 + | value.into_inner()
|
1876 + | }
|
1877 + | }
|
1878 + | impl crate::constrained::Constrained for BooleanSet {
|
1879 + | type Unconstrained = crate::unconstrained::boolean_set_unconstrained::BooleanSetUnconstrained;
|
1880 + | }
|
1881 + |
|
2334 1882 | #[allow(missing_docs)] // documentation missing in model
|
2335 1883 | ///
|
2336 1884 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2337 - | /// [constraint traits]. Use [`MaxByte::try_from`] to construct values of this type.
|
1885 + | /// [constraint traits]. Use [`StringSet::try_from`] to construct values of this type.
|
2338 1886 | ///
|
2339 1887 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2340 1888 | ///
|
2341 1889 | #[derive(
|
2342 1890 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2343 1891 | )]
|
2344 - | pub struct MaxByte(pub(crate) i8);
|
2345 - | impl MaxByte {
|
2346 - | /// Returns an immutable reference to the underlying [`i8`].
|
2347 - | pub fn inner(&self) -> &i8 {
|
1892 + | pub struct StringSet(pub(crate) ::std::vec::Vec<::std::string::String>);
|
1893 + | impl StringSet {
|
1894 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<::std::string::String>`].
|
1895 + | pub fn inner(&self) -> &::std::vec::Vec<::std::string::String> {
|
2348 1896 | &self.0
|
2349 1897 | }
|
2350 - |
|
2351 - | /// Consumes the value, returning the underlying [`i8`].
|
2352 - | pub fn into_inner(self) -> i8 {
|
1898 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<::std::string::String>`].
|
1899 + | pub fn into_inner(self) -> ::std::vec::Vec<::std::string::String> {
|
2353 1900 | self.0
|
2354 1901 | }
|
2355 - | }
|
2356 - |
|
2357 - | impl crate::constrained::Constrained for MaxByte {
|
2358 - | type Unconstrained = i8;
|
2359 - | }
|
2360 1902 |
|
2361 - | impl ::std::convert::From<i8> for crate::constrained::MaybeConstrained<crate::model::MaxByte> {
|
2362 - | fn from(value: i8) -> Self {
|
2363 - | Self::Unconstrained(value)
|
1903 + | fn check_unique_items(
|
1904 + | items: ::std::vec::Vec<::std::string::String>,
|
1905 + | ) -> ::std::result::Result<
|
1906 + | ::std::vec::Vec<::std::string::String>,
|
1907 + | crate::model::string_set::ConstraintViolation,
|
1908 + | > {
|
1909 + | let mut seen = ::std::collections::HashMap::new();
|
1910 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
1911 + | for (idx, item) in items.iter().enumerate() {
|
1912 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
1913 + | duplicate_indices.push(prev_idx);
|
2364 1914 | }
|
2365 - | }
|
2366 - |
|
2367 - | impl ::std::fmt::Display for MaxByte {
|
2368 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2369 - | self.0.fmt(f)
|
2370 1915 | }
|
2371 - | }
|
2372 1916 |
|
2373 - | impl ::std::convert::From<MaxByte> for i8 {
|
2374 - | fn from(value: MaxByte) -> Self {
|
2375 - | value.into_inner()
|
1917 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
1918 + | for idx in &duplicate_indices {
|
1919 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
1920 + | last_duplicate_indices.push(prev_idx);
|
2376 1921 | }
|
2377 - | }
|
2378 - | impl MaxByte {
|
2379 - | fn check_range(
|
2380 - | value: i8,
|
2381 - | ) -> ::std::result::Result<(), crate::model::max_byte::ConstraintViolation> {
|
2382 - | if value <= 8 {
|
2383 - | Ok(())
|
1922 + | }
|
1923 + | duplicate_indices.extend(last_duplicate_indices);
|
1924 + |
|
1925 + | if !duplicate_indices.is_empty() {
|
1926 + | debug_assert!(duplicate_indices.len() >= 2);
|
1927 + | Err(crate::model::string_set::ConstraintViolation::UniqueItems {
|
1928 + | duplicate_indices,
|
1929 + | original: items,
|
1930 + | })
|
2384 1931 | } else {
|
2385 - | Err(crate::model::max_byte::ConstraintViolation::Range(value))
|
1932 + | Ok(items)
|
2386 1933 | }
|
2387 1934 | }
|
2388 1935 | }
|
2389 - | impl ::std::convert::TryFrom<i8> for MaxByte {
|
2390 - | type Error = crate::model::max_byte::ConstraintViolation;
|
1936 + | impl ::std::convert::TryFrom<::std::vec::Vec<::std::string::String>> for StringSet {
|
1937 + | type Error = crate::model::string_set::ConstraintViolation;
|
2391 1938 |
|
2392 - | /// Constructs a `MaxByte` from an [`i8`], failing when the provided value does not satisfy the modeled constraints.
|
2393 - | fn try_from(value: i8) -> ::std::result::Result<Self, Self::Error> {
|
2394 - | Self::check_range(value)?;
|
1939 + | /// Constructs a `StringSet` from an [`::std::vec::Vec<::std::string::String>`], failing when the provided value does not satisfy the modeled constraints.
|
1940 + | fn try_from(
|
1941 + | value: ::std::vec::Vec<::std::string::String>,
|
1942 + | ) -> ::std::result::Result<Self, Self::Error> {
|
1943 + | let value = Self::check_unique_items(value)?;
|
2395 1944 |
|
2396 1945 | Ok(Self(value))
|
2397 1946 | }
|
2398 1947 | }
|
2399 1948 |
|
1949 + | impl ::std::convert::From<StringSet> for ::std::vec::Vec<::std::string::String> {
|
1950 + | fn from(value: StringSet) -> Self {
|
1951 + | value.into_inner()
|
1952 + | }
|
1953 + | }
|
1954 + | impl crate::constrained::Constrained for StringSet {
|
1955 + | type Unconstrained = crate::unconstrained::string_set_unconstrained::StringSetUnconstrained;
|
1956 + | }
|
1957 + |
|
2400 1958 | #[allow(missing_docs)] // documentation missing in model
|
2401 1959 | ///
|
2402 1960 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2403 - | /// [constraint traits]. Use [`MinByte::try_from`] to construct values of this type.
|
1961 + | /// [constraint traits]. Use [`ByteSet::try_from`] to construct values of this type.
|
2404 1962 | ///
|
2405 1963 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2406 1964 | ///
|
2407 1965 | #[derive(
|
2408 1966 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2409 1967 | )]
|
2410 - | pub struct MinByte(pub(crate) i8);
|
2411 - | impl MinByte {
|
2412 - | /// Returns an immutable reference to the underlying [`i8`].
|
2413 - | pub fn inner(&self) -> &i8 {
|
1968 + | pub struct ByteSet(pub(crate) ::std::vec::Vec<i8>);
|
1969 + | impl ByteSet {
|
1970 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<i8>`].
|
1971 + | pub fn inner(&self) -> &::std::vec::Vec<i8> {
|
2414 1972 | &self.0
|
2415 1973 | }
|
2416 - |
|
2417 - | /// Consumes the value, returning the underlying [`i8`].
|
2418 - | pub fn into_inner(self) -> i8 {
|
1974 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<i8>`].
|
1975 + | pub fn into_inner(self) -> ::std::vec::Vec<i8> {
|
2419 1976 | self.0
|
2420 1977 | }
|
2421 - | }
|
2422 - |
|
2423 - | impl crate::constrained::Constrained for MinByte {
|
2424 - | type Unconstrained = i8;
|
2425 - | }
|
2426 1978 |
|
2427 - | impl ::std::convert::From<i8> for crate::constrained::MaybeConstrained<crate::model::MinByte> {
|
2428 - | fn from(value: i8) -> Self {
|
2429 - | Self::Unconstrained(value)
|
1979 + | fn check_unique_items(
|
1980 + | items: ::std::vec::Vec<i8>,
|
1981 + | ) -> ::std::result::Result<::std::vec::Vec<i8>, crate::model::byte_set::ConstraintViolation>
|
1982 + | {
|
1983 + | let mut seen = ::std::collections::HashMap::new();
|
1984 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
1985 + | for (idx, item) in items.iter().enumerate() {
|
1986 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
1987 + | duplicate_indices.push(prev_idx);
|
2430 1988 | }
|
2431 - | }
|
2432 - |
|
2433 - | impl ::std::fmt::Display for MinByte {
|
2434 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2435 - | self.0.fmt(f)
|
2436 1989 | }
|
2437 - | }
|
2438 1990 |
|
2439 - | impl ::std::convert::From<MinByte> for i8 {
|
2440 - | fn from(value: MinByte) -> Self {
|
2441 - | value.into_inner()
|
1991 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
1992 + | for idx in &duplicate_indices {
|
1993 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
1994 + | last_duplicate_indices.push(prev_idx);
|
2442 1995 | }
|
2443 - | }
|
2444 - | impl MinByte {
|
2445 - | fn check_range(
|
2446 - | value: i8,
|
2447 - | ) -> ::std::result::Result<(), crate::model::min_byte::ConstraintViolation> {
|
2448 - | if 2 <= value {
|
2449 - | Ok(())
|
1996 + | }
|
1997 + | duplicate_indices.extend(last_duplicate_indices);
|
1998 + |
|
1999 + | if !duplicate_indices.is_empty() {
|
2000 + | debug_assert!(duplicate_indices.len() >= 2);
|
2001 + | Err(crate::model::byte_set::ConstraintViolation::UniqueItems {
|
2002 + | duplicate_indices,
|
2003 + | original: items,
|
2004 + | })
|
2450 2005 | } else {
|
2451 - | Err(crate::model::min_byte::ConstraintViolation::Range(value))
|
2006 + | Ok(items)
|
2452 2007 | }
|
2453 2008 | }
|
2454 2009 | }
|
2455 - | impl ::std::convert::TryFrom<i8> for MinByte {
|
2456 - | type Error = crate::model::min_byte::ConstraintViolation;
|
2010 + | impl ::std::convert::TryFrom<::std::vec::Vec<i8>> for ByteSet {
|
2011 + | type Error = crate::model::byte_set::ConstraintViolation;
|
2457 2012 |
|
2458 - | /// Constructs a `MinByte` from an [`i8`], failing when the provided value does not satisfy the modeled constraints.
|
2459 - | fn try_from(value: i8) -> ::std::result::Result<Self, Self::Error> {
|
2460 - | Self::check_range(value)?;
|
2013 + | /// Constructs a `ByteSet` from an [`::std::vec::Vec<i8>`], failing when the provided value does not satisfy the modeled constraints.
|
2014 + | fn try_from(value: ::std::vec::Vec<i8>) -> ::std::result::Result<Self, Self::Error> {
|
2015 + | let value = Self::check_unique_items(value)?;
|
2461 2016 |
|
2462 2017 | Ok(Self(value))
|
2463 2018 | }
|
2464 2019 | }
|
2465 2020 |
|
2021 + | impl ::std::convert::From<ByteSet> for ::std::vec::Vec<i8> {
|
2022 + | fn from(value: ByteSet) -> Self {
|
2023 + | value.into_inner()
|
2024 + | }
|
2025 + | }
|
2026 + | impl crate::constrained::Constrained for ByteSet {
|
2027 + | type Unconstrained = crate::unconstrained::byte_set_unconstrained::ByteSetUnconstrained;
|
2028 + | }
|
2029 + |
|
2466 2030 | #[allow(missing_docs)] // documentation missing in model
|
2467 2031 | ///
|
2468 2032 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2469 - | /// [constraint traits]. Use [`RangeByte::try_from`] to construct values of this type.
|
2033 + | /// [constraint traits]. Use [`ShortSet::try_from`] to construct values of this type.
|
2470 2034 | ///
|
2471 2035 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2472 2036 | ///
|
2473 2037 | #[derive(
|
2474 2038 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2475 2039 | )]
|
2476 - | pub struct RangeByte(pub(crate) i8);
|
2477 - | impl RangeByte {
|
2478 - | /// Returns an immutable reference to the underlying [`i8`].
|
2479 - | pub fn inner(&self) -> &i8 {
|
2040 + | pub struct ShortSet(pub(crate) ::std::vec::Vec<i16>);
|
2041 + | impl ShortSet {
|
2042 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<i16>`].
|
2043 + | pub fn inner(&self) -> &::std::vec::Vec<i16> {
|
2480 2044 | &self.0
|
2481 2045 | }
|
2482 - |
|
2483 - | /// Consumes the value, returning the underlying [`i8`].
|
2484 - | pub fn into_inner(self) -> i8 {
|
2046 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<i16>`].
|
2047 + | pub fn into_inner(self) -> ::std::vec::Vec<i16> {
|
2485 2048 | self.0
|
2486 2049 | }
|
2487 - | }
|
2488 - |
|
2489 - | impl crate::constrained::Constrained for RangeByte {
|
2490 - | type Unconstrained = i8;
|
2491 - | }
|
2492 2050 |
|
2493 - | impl ::std::convert::From<i8> for crate::constrained::MaybeConstrained<crate::model::RangeByte> {
|
2494 - | fn from(value: i8) -> Self {
|
2495 - | Self::Unconstrained(value)
|
2051 + | fn check_unique_items(
|
2052 + | items: ::std::vec::Vec<i16>,
|
2053 + | ) -> ::std::result::Result<::std::vec::Vec<i16>, crate::model::short_set::ConstraintViolation>
|
2054 + | {
|
2055 + | let mut seen = ::std::collections::HashMap::new();
|
2056 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
2057 + | for (idx, item) in items.iter().enumerate() {
|
2058 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
2059 + | duplicate_indices.push(prev_idx);
|
2496 2060 | }
|
2497 - | }
|
2498 - |
|
2499 - | impl ::std::fmt::Display for RangeByte {
|
2500 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2501 - | self.0.fmt(f)
|
2502 2061 | }
|
2503 - | }
|
2504 2062 |
|
2505 - | impl ::std::convert::From<RangeByte> for i8 {
|
2506 - | fn from(value: RangeByte) -> Self {
|
2507 - | value.into_inner()
|
2063 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
2064 + | for idx in &duplicate_indices {
|
2065 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
2066 + | last_duplicate_indices.push(prev_idx);
|
2508 2067 | }
|
2509 - | }
|
2510 - | impl RangeByte {
|
2511 - | fn check_range(
|
2512 - | value: i8,
|
2513 - | ) -> ::std::result::Result<(), crate::model::range_byte::ConstraintViolation> {
|
2514 - | if (2..=8).contains(&value) {
|
2515 - | Ok(())
|
2068 + | }
|
2069 + | duplicate_indices.extend(last_duplicate_indices);
|
2070 + |
|
2071 + | if !duplicate_indices.is_empty() {
|
2072 + | debug_assert!(duplicate_indices.len() >= 2);
|
2073 + | Err(crate::model::short_set::ConstraintViolation::UniqueItems {
|
2074 + | duplicate_indices,
|
2075 + | original: items,
|
2076 + | })
|
2516 2077 | } else {
|
2517 - | Err(crate::model::range_byte::ConstraintViolation::Range(value))
|
2078 + | Ok(items)
|
2518 2079 | }
|
2519 2080 | }
|
2520 2081 | }
|
2521 - | impl ::std::convert::TryFrom<i8> for RangeByte {
|
2522 - | type Error = crate::model::range_byte::ConstraintViolation;
|
2082 + | impl ::std::convert::TryFrom<::std::vec::Vec<i16>> for ShortSet {
|
2083 + | type Error = crate::model::short_set::ConstraintViolation;
|
2523 2084 |
|
2524 - | /// Constructs a `RangeByte` from an [`i8`], failing when the provided value does not satisfy the modeled constraints.
|
2525 - | fn try_from(value: i8) -> ::std::result::Result<Self, Self::Error> {
|
2526 - | Self::check_range(value)?;
|
2085 + | /// Constructs a `ShortSet` from an [`::std::vec::Vec<i16>`], failing when the provided value does not satisfy the modeled constraints.
|
2086 + | fn try_from(value: ::std::vec::Vec<i16>) -> ::std::result::Result<Self, Self::Error> {
|
2087 + | let value = Self::check_unique_items(value)?;
|
2527 2088 |
|
2528 2089 | Ok(Self(value))
|
2529 2090 | }
|
2530 2091 | }
|
2531 2092 |
|
2532 - | #[allow(missing_docs)] // documentation missing in model
|
2533 - | #[derive(
|
2534 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2535 - | )]
|
2536 - | pub enum PatternUnionOverride {
|
2537 - | #[allow(missing_docs)] // documentation missing in model
|
2538 - | First(crate::model::pattern_union_override::First),
|
2539 - | #[allow(missing_docs)] // documentation missing in model
|
2540 - | Second(crate::model::pattern_union_override::Second),
|
2541 - | }
|
2542 - | impl PatternUnionOverride {
|
2543 - | /// Tries to convert the enum instance into [`First`](crate::model::PatternUnionOverride::First), extracting the inner [`First`](crate::model::pattern_union_override::First).
|
2544 - | /// Returns `Err(&Self)` if it can't be converted.
|
2545 - | pub fn as_first(
|
2546 - | &self,
|
2547 - | ) -> ::std::result::Result<&crate::model::pattern_union_override::First, &Self> {
|
2548 - | if let PatternUnionOverride::First(val) = &self {
|
2549 - | ::std::result::Result::Ok(val)
|
2550 - | } else {
|
2551 - | ::std::result::Result::Err(self)
|
2552 - | }
|
2553 - | }
|
2554 - | /// Returns true if this is a [`First`](crate::model::PatternUnionOverride::First).
|
2555 - | pub fn is_first(&self) -> bool {
|
2556 - | self.as_first().is_ok()
|
2557 - | }
|
2558 - | /// Tries to convert the enum instance into [`Second`](crate::model::PatternUnionOverride::Second), extracting the inner [`Second`](crate::model::pattern_union_override::Second).
|
2559 - | /// Returns `Err(&Self)` if it can't be converted.
|
2560 - | pub fn as_second(
|
2561 - | &self,
|
2562 - | ) -> ::std::result::Result<&crate::model::pattern_union_override::Second, &Self> {
|
2563 - | if let PatternUnionOverride::Second(val) = &self {
|
2564 - | ::std::result::Result::Ok(val)
|
2565 - | } else {
|
2566 - | ::std::result::Result::Err(self)
|
2567 - | }
|
2568 - | }
|
2569 - | /// Returns true if this is a [`Second`](crate::model::PatternUnionOverride::Second).
|
2570 - | pub fn is_second(&self) -> bool {
|
2571 - | self.as_second().is_ok()
|
2093 + | impl ::std::convert::From<ShortSet> for ::std::vec::Vec<i16> {
|
2094 + | fn from(value: ShortSet) -> Self {
|
2095 + | value.into_inner()
|
2572 2096 | }
|
2573 2097 | }
|
2574 - |
|
2575 - | #[allow(missing_docs)] // documentation missing in model
|
2576 - | #[derive(
|
2577 - | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2578 - | )]
|
2579 - | pub enum PatternUnion {
|
2580 - | #[allow(missing_docs)] // documentation missing in model
|
2581 - | First(crate::model::PatternString),
|
2582 - | #[allow(missing_docs)] // documentation missing in model
|
2583 - | Second(crate::model::PatternString),
|
2584 - | }
|
2585 - | impl PatternUnion {
|
2586 - | /// Tries to convert the enum instance into [`First`](crate::model::PatternUnion::First), extracting the inner [`PatternString`](crate::model::PatternString).
|
2587 - | /// Returns `Err(&Self)` if it can't be converted.
|
2588 - | pub fn as_first(&self) -> ::std::result::Result<&crate::model::PatternString, &Self> {
|
2589 - | if let PatternUnion::First(val) = &self {
|
2590 - | ::std::result::Result::Ok(val)
|
2591 - | } else {
|
2592 - | ::std::result::Result::Err(self)
|
2593 - | }
|
2594 - | }
|
2595 - | /// Returns true if this is a [`First`](crate::model::PatternUnion::First).
|
2596 - | pub fn is_first(&self) -> bool {
|
2597 - | self.as_first().is_ok()
|
2598 - | }
|
2599 - | /// Tries to convert the enum instance into [`Second`](crate::model::PatternUnion::Second), extracting the inner [`PatternString`](crate::model::PatternString).
|
2600 - | /// Returns `Err(&Self)` if it can't be converted.
|
2601 - | pub fn as_second(&self) -> ::std::result::Result<&crate::model::PatternString, &Self> {
|
2602 - | if let PatternUnion::Second(val) = &self {
|
2603 - | ::std::result::Result::Ok(val)
|
2604 - | } else {
|
2605 - | ::std::result::Result::Err(self)
|
2606 - | }
|
2607 - | }
|
2608 - | /// Returns true if this is a [`Second`](crate::model::PatternUnion::Second).
|
2609 - | pub fn is_second(&self) -> bool {
|
2610 - | self.as_second().is_ok()
|
2611 - | }
|
2098 + | impl crate::constrained::Constrained for ShortSet {
|
2099 + | type Unconstrained = crate::unconstrained::short_set_unconstrained::ShortSetUnconstrained;
|
2612 2100 | }
|
2613 2101 |
|
2614 2102 | #[allow(missing_docs)] // documentation missing in model
|
2615 2103 | ///
|
2616 2104 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2617 - | /// [constraint traits]. Use [`PatternString::try_from`] to construct values of this type.
|
2105 + | /// [constraint traits]. Use [`IntegerSet::try_from`] to construct values of this type.
|
2618 2106 | ///
|
2619 2107 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2620 2108 | ///
|
2621 2109 | #[derive(
|
2622 2110 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2623 2111 | )]
|
2624 - | pub struct PatternString(pub(crate) ::std::string::String);
|
2625 - | impl PatternString {
|
2626 - | /// Extracts a string slice containing the entire underlying `String`.
|
2627 - | pub fn as_str(&self) -> &str {
|
2112 + | pub struct IntegerSet(pub(crate) ::std::vec::Vec<i32>);
|
2113 + | impl IntegerSet {
|
2114 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<i32>`].
|
2115 + | pub fn inner(&self) -> &::std::vec::Vec<i32> {
|
2628 2116 | &self.0
|
2629 2117 | }
|
2630 - |
|
2631 - | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
2632 - | pub fn inner(&self) -> &::std::string::String {
|
2633 - | &self.0
|
2118 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<i32>`].
|
2119 + | pub fn into_inner(self) -> ::std::vec::Vec<i32> {
|
2120 + | self.0
|
2634 2121 | }
|
2635 2122 |
|
2636 - | /// Consumes the value, returning the underlying [`::std::string::String`].
|
2637 - | pub fn into_inner(self) -> ::std::string::String {
|
2638 - | self.0
|
2123 + | fn check_unique_items(
|
2124 + | items: ::std::vec::Vec<i32>,
|
2125 + | ) -> ::std::result::Result<::std::vec::Vec<i32>, crate::model::integer_set::ConstraintViolation>
|
2126 + | {
|
2127 + | let mut seen = ::std::collections::HashMap::new();
|
2128 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
2129 + | for (idx, item) in items.iter().enumerate() {
|
2130 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
2131 + | duplicate_indices.push(prev_idx);
|
2132 + | }
|
2639 2133 | }
|
2640 - | }
|
2641 - | impl PatternString {
|
2642 - | fn check_pattern(
|
2643 - | string: ::std::string::String,
|
2644 - | ) -> ::std::result::Result<
|
2645 - | ::std::string::String,
|
2646 - | crate::model::pattern_string::ConstraintViolation,
|
2647 - | > {
|
2648 - | let regex = Self::compile_regex();
|
2649 2134 |
|
2650 - | if regex.is_match(&string) {
|
2651 - | Ok(string)
|
2652 - | } else {
|
2653 - | Err(crate::model::pattern_string::ConstraintViolation::Pattern(
|
2654 - | string,
|
2655 - | ))
|
2135 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
2136 + | for idx in &duplicate_indices {
|
2137 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
2138 + | last_duplicate_indices.push(prev_idx);
|
2656 2139 | }
|
2657 2140 | }
|
2141 + | duplicate_indices.extend(last_duplicate_indices);
|
2658 2142 |
|
2659 - | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
2660 - | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
2661 - | pub fn compile_regex() -> &'static ::regex::Regex {
|
2662 - | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
2663 - | ::regex::Regex::new(r#"^[a-m]+$"#).expect(r#"The regular expression ^[a-m]+$ is not supported by the `regex` crate; feel free to file an issue under https://github.com/smithy-lang/smithy-rs/issues for support"#)
|
2664 - | });
|
2665 - |
|
2666 - | ®EX
|
2143 + | if !duplicate_indices.is_empty() {
|
2144 + | debug_assert!(duplicate_indices.len() >= 2);
|
2145 + | Err(
|
2146 + | crate::model::integer_set::ConstraintViolation::UniqueItems {
|
2147 + | duplicate_indices,
|
2148 + | original: items,
|
2149 + | },
|
2150 + | )
|
2151 + | } else {
|
2152 + | Ok(items)
|
2667 2153 | }
|
2668 - | }
|
2669 - | impl ::std::convert::TryFrom<::std::string::String> for PatternString {
|
2670 - | type Error = crate::model::pattern_string::ConstraintViolation;
|
2671 - |
|
2672 - | /// Constructs a `PatternString` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
2673 - | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
2674 - | let value = Self::check_pattern(value)?;
|
2675 - |
|
2676 - | Ok(Self(value))
|
2677 2154 | }
|
2678 2155 | }
|
2679 - | impl crate::constrained::Constrained for PatternString {
|
2680 - | type Unconstrained = ::std::string::String;
|
2681 - | }
|
2156 + | impl ::std::convert::TryFrom<::std::vec::Vec<i32>> for IntegerSet {
|
2157 + | type Error = crate::model::integer_set::ConstraintViolation;
|
2682 2158 |
|
2683 - | impl ::std::convert::From<::std::string::String>
|
2684 - | for crate::constrained::MaybeConstrained<crate::model::PatternString>
|
2685 - | {
|
2686 - | fn from(value: ::std::string::String) -> Self {
|
2687 - | Self::Unconstrained(value)
|
2688 - | }
|
2689 - | }
|
2159 + | /// Constructs a `IntegerSet` from an [`::std::vec::Vec<i32>`], failing when the provided value does not satisfy the modeled constraints.
|
2160 + | fn try_from(value: ::std::vec::Vec<i32>) -> ::std::result::Result<Self, Self::Error> {
|
2161 + | let value = Self::check_unique_items(value)?;
|
2690 2162 |
|
2691 - | impl ::std::fmt::Display for PatternString {
|
2692 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2693 - | self.0.fmt(f)
|
2163 + | Ok(Self(value))
|
2694 2164 | }
|
2695 2165 | }
|
2696 2166 |
|
2697 - | impl ::std::convert::From<PatternString> for ::std::string::String {
|
2698 - | fn from(value: PatternString) -> Self {
|
2167 + | impl ::std::convert::From<IntegerSet> for ::std::vec::Vec<i32> {
|
2168 + | fn from(value: IntegerSet) -> Self {
|
2699 2169 | value.into_inner()
|
2700 2170 | }
|
2701 2171 | }
|
2702 - |
|
2703 - | #[cfg(test)]
|
2704 - | mod test_pattern_string {
|
2705 - | #[test]
|
2706 - | fn regex_compiles() {
|
2707 - | crate::model::PatternString::compile_regex();
|
2708 - | }
|
2172 + | impl crate::constrained::Constrained for IntegerSet {
|
2173 + | type Unconstrained = crate::unconstrained::integer_set_unconstrained::IntegerSetUnconstrained;
|
2709 2174 | }
|
2710 2175 |
|
2711 2176 | #[allow(missing_docs)] // documentation missing in model
|
2712 2177 | ///
|
2713 2178 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2714 - | /// [constraint traits]. Use [`EvilString::try_from`] to construct values of this type.
|
2179 + | /// [constraint traits]. Use [`LongSet::try_from`] to construct values of this type.
|
2715 2180 | ///
|
2716 2181 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2717 2182 | ///
|
2718 2183 | #[derive(
|
2719 2184 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2720 2185 | )]
|
2721 - | pub struct EvilString(pub(crate) ::std::string::String);
|
2722 - | impl EvilString {
|
2723 - | /// Extracts a string slice containing the entire underlying `String`.
|
2724 - | pub fn as_str(&self) -> &str {
|
2725 - | &self.0
|
2726 - | }
|
2727 - |
|
2728 - | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
2729 - | pub fn inner(&self) -> &::std::string::String {
|
2186 + | pub struct LongSet(pub(crate) ::std::vec::Vec<i64>);
|
2187 + | impl LongSet {
|
2188 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<i64>`].
|
2189 + | pub fn inner(&self) -> &::std::vec::Vec<i64> {
|
2730 2190 | &self.0
|
2731 2191 | }
|
2732 - |
|
2733 - | /// Consumes the value, returning the underlying [`::std::string::String`].
|
2734 - | pub fn into_inner(self) -> ::std::string::String {
|
2192 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<i64>`].
|
2193 + | pub fn into_inner(self) -> ::std::vec::Vec<i64> {
|
2735 2194 | self.0
|
2736 2195 | }
|
2737 - | }
|
2738 - | impl EvilString {
|
2739 - | fn check_pattern(
|
2740 - | string: ::std::string::String,
|
2741 - | ) -> ::std::result::Result<::std::string::String, crate::model::evil_string::ConstraintViolation>
|
2742 - | {
|
2743 - | let regex = Self::compile_regex();
|
2744 2196 |
|
2745 - | if regex.is_match(&string) {
|
2746 - | Ok(string)
|
2747 - | } else {
|
2748 - | Err(crate::model::evil_string::ConstraintViolation::Pattern(
|
2749 - | string,
|
2750 - | ))
|
2197 + | fn check_unique_items(
|
2198 + | items: ::std::vec::Vec<i64>,
|
2199 + | ) -> ::std::result::Result<::std::vec::Vec<i64>, crate::model::long_set::ConstraintViolation>
|
2200 + | {
|
2201 + | let mut seen = ::std::collections::HashMap::new();
|
2202 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
2203 + | for (idx, item) in items.iter().enumerate() {
|
2204 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
2205 + | duplicate_indices.push(prev_idx);
|
2751 2206 | }
|
2752 2207 | }
|
2753 2208 |
|
2754 - | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
2755 - | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
2756 - | pub fn compile_regex() -> &'static ::regex::Regex {
|
2757 - | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
2758 - | ::regex::Regex::new(r#"^([0-9]+)+$"#).expect(r#"The regular expression ^([0-9]+)+$ is not supported by the `regex` crate; feel free to file an issue under https://github.com/smithy-lang/smithy-rs/issues for support"#)
|
2759 - | });
|
2760 - |
|
2761 - | ®EX
|
2209 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
2210 + | for idx in &duplicate_indices {
|
2211 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
2212 + | last_duplicate_indices.push(prev_idx);
|
2762 2213 | }
|
2763 - | }
|
2764 - | impl ::std::convert::TryFrom<::std::string::String> for EvilString {
|
2765 - | type Error = crate::model::evil_string::ConstraintViolation;
|
2766 - |
|
2767 - | /// Constructs a `EvilString` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
2768 - | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
2769 - | let value = Self::check_pattern(value)?;
|
2770 - |
|
2771 - | Ok(Self(value))
|
2772 2214 | }
|
2773 - | }
|
2774 - | impl crate::constrained::Constrained for EvilString {
|
2775 - | type Unconstrained = ::std::string::String;
|
2776 - | }
|
2215 + | duplicate_indices.extend(last_duplicate_indices);
|
2777 2216 |
|
2778 - | impl ::std::convert::From<::std::string::String>
|
2779 - | for crate::constrained::MaybeConstrained<crate::model::EvilString>
|
2780 - | {
|
2781 - | fn from(value: ::std::string::String) -> Self {
|
2782 - | Self::Unconstrained(value)
|
2217 + | if !duplicate_indices.is_empty() {
|
2218 + | debug_assert!(duplicate_indices.len() >= 2);
|
2219 + | Err(crate::model::long_set::ConstraintViolation::UniqueItems {
|
2220 + | duplicate_indices,
|
2221 + | original: items,
|
2222 + | })
|
2223 + | } else {
|
2224 + | Ok(items)
|
2225 + | }
|
2783 2226 | }
|
2784 2227 | }
|
2228 + | impl ::std::convert::TryFrom<::std::vec::Vec<i64>> for LongSet {
|
2229 + | type Error = crate::model::long_set::ConstraintViolation;
|
2785 2230 |
|
2786 - | impl ::std::fmt::Display for EvilString {
|
2787 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2788 - | self.0.fmt(f)
|
2231 + | /// Constructs a `LongSet` from an [`::std::vec::Vec<i64>`], failing when the provided value does not satisfy the modeled constraints.
|
2232 + | fn try_from(value: ::std::vec::Vec<i64>) -> ::std::result::Result<Self, Self::Error> {
|
2233 + | let value = Self::check_unique_items(value)?;
|
2234 + |
|
2235 + | Ok(Self(value))
|
2789 2236 | }
|
2790 2237 | }
|
2791 2238 |
|
2792 - | impl ::std::convert::From<EvilString> for ::std::string::String {
|
2793 - | fn from(value: EvilString) -> Self {
|
2239 + | impl ::std::convert::From<LongSet> for ::std::vec::Vec<i64> {
|
2240 + | fn from(value: LongSet) -> Self {
|
2794 2241 | value.into_inner()
|
2795 2242 | }
|
2796 2243 | }
|
2797 - |
|
2798 - | #[cfg(test)]
|
2799 - | mod test_evil_string {
|
2800 - | #[test]
|
2801 - | fn regex_compiles() {
|
2802 - | crate::model::EvilString::compile_regex();
|
2803 - | }
|
2244 + | impl crate::constrained::Constrained for LongSet {
|
2245 + | type Unconstrained = crate::unconstrained::long_set_unconstrained::LongSetUnconstrained;
|
2804 2246 | }
|
2805 2247 |
|
2806 2248 | #[allow(missing_docs)] // documentation missing in model
|
2807 2249 | ///
|
2808 2250 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2809 - | /// [constraint traits]. Use [`LengthString::try_from`] to construct values of this type.
|
2251 + | /// [constraint traits]. Use [`TimestampSet::try_from`] to construct values of this type.
|
2810 2252 | ///
|
2811 2253 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2812 2254 | ///
|
2813 2255 | #[derive(
|
2814 2256 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2815 2257 | )]
|
2816 - | pub struct LengthString(pub(crate) ::std::string::String);
|
2817 - | impl LengthString {
|
2818 - | /// Extracts a string slice containing the entire underlying `String`.
|
2819 - | pub fn as_str(&self) -> &str {
|
2258 + | pub struct TimestampSet(pub(crate) ::std::vec::Vec<::aws_smithy_types::DateTime>);
|
2259 + | impl TimestampSet {
|
2260 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<::aws_smithy_types::DateTime>`].
|
2261 + | pub fn inner(&self) -> &::std::vec::Vec<::aws_smithy_types::DateTime> {
|
2820 2262 | &self.0
|
2821 2263 | }
|
2264 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<::aws_smithy_types::DateTime>`].
|
2265 + | pub fn into_inner(self) -> ::std::vec::Vec<::aws_smithy_types::DateTime> {
|
2266 + | self.0
|
2267 + | }
|
2822 2268 |
|
2823 - | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
2824 - | pub fn inner(&self) -> &::std::string::String {
|
2825 - | &self.0
|
2269 + | fn check_unique_items(
|
2270 + | items: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
2271 + | ) -> ::std::result::Result<
|
2272 + | ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
2273 + | crate::model::timestamp_set::ConstraintViolation,
|
2274 + | > {
|
2275 + | let mut seen = ::std::collections::HashMap::new();
|
2276 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
2277 + | for (idx, item) in items.iter().enumerate() {
|
2278 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
2279 + | duplicate_indices.push(prev_idx);
|
2280 + | }
|
2826 2281 | }
|
2827 2282 |
|
2828 - | /// Consumes the value, returning the underlying [`::std::string::String`].
|
2829 - | pub fn into_inner(self) -> ::std::string::String {
|
2830 - | self.0
|
2283 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
2284 + | for idx in &duplicate_indices {
|
2285 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
2286 + | last_duplicate_indices.push(prev_idx);
|
2831 2287 | }
|
2832 - | }
|
2833 - | impl LengthString {
|
2834 - | fn check_length(
|
2835 - | string: &str,
|
2836 - | ) -> ::std::result::Result<(), crate::model::length_string::ConstraintViolation> {
|
2837 - | let length = string.chars().count();
|
2288 + | }
|
2289 + | duplicate_indices.extend(last_duplicate_indices);
|
2838 2290 |
|
2839 - | if (2..=8).contains(&length) {
|
2840 - | Ok(())
|
2291 + | if !duplicate_indices.is_empty() {
|
2292 + | debug_assert!(duplicate_indices.len() >= 2);
|
2293 + | Err(
|
2294 + | crate::model::timestamp_set::ConstraintViolation::UniqueItems {
|
2295 + | duplicate_indices,
|
2296 + | original: items,
|
2297 + | },
|
2298 + | )
|
2841 2299 | } else {
|
2842 - | Err(crate::model::length_string::ConstraintViolation::Length(
|
2843 - | length,
|
2844 - | ))
|
2300 + | Ok(items)
|
2845 2301 | }
|
2846 2302 | }
|
2847 2303 | }
|
2848 - | impl ::std::convert::TryFrom<::std::string::String> for LengthString {
|
2849 - | type Error = crate::model::length_string::ConstraintViolation;
|
2304 + | impl ::std::convert::TryFrom<::std::vec::Vec<::aws_smithy_types::DateTime>> for TimestampSet {
|
2305 + | type Error = crate::model::timestamp_set::ConstraintViolation;
|
2850 2306 |
|
2851 - | /// Constructs a `LengthString` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
2852 - | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
2853 - | Self::check_length(&value)?;
|
2307 + | /// Constructs a `TimestampSet` from an [`::std::vec::Vec<::aws_smithy_types::DateTime>`], failing when the provided value does not satisfy the modeled constraints.
|
2308 + | fn try_from(
|
2309 + | value: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
2310 + | ) -> ::std::result::Result<Self, Self::Error> {
|
2311 + | let value = Self::check_unique_items(value)?;
|
2854 2312 |
|
2855 2313 | Ok(Self(value))
|
2856 2314 | }
|
2857 2315 | }
|
2858 - | impl crate::constrained::Constrained for LengthString {
|
2859 - | type Unconstrained = ::std::string::String;
|
2860 - | }
|
2861 2316 |
|
2862 - | impl ::std::convert::From<::std::string::String>
|
2863 - | for crate::constrained::MaybeConstrained<crate::model::LengthString>
|
2864 - | {
|
2865 - | fn from(value: ::std::string::String) -> Self {
|
2866 - | Self::Unconstrained(value)
|
2317 + | impl ::std::convert::From<TimestampSet> for ::std::vec::Vec<::aws_smithy_types::DateTime> {
|
2318 + | fn from(value: TimestampSet) -> Self {
|
2319 + | value.into_inner()
|
2867 2320 | }
|
2868 2321 | }
|
2869 - |
|
2870 - | impl ::std::fmt::Display for LengthString {
|
2871 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2872 - | self.0.fmt(f)
|
2873 - | }
|
2874 - | }
|
2875 - |
|
2876 - | impl ::std::convert::From<LengthString> for ::std::string::String {
|
2877 - | fn from(value: LengthString) -> Self {
|
2878 - | value.into_inner()
|
2879 - | }
|
2322 + | impl crate::constrained::Constrained for TimestampSet {
|
2323 + | type Unconstrained =
|
2324 + | crate::unconstrained::timestamp_set_unconstrained::TimestampSetUnconstrained;
|
2880 2325 | }
|
2881 2326 |
|
2882 2327 | #[allow(missing_docs)] // documentation missing in model
|
2883 2328 | ///
|
2884 2329 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2885 - | /// [constraint traits]. Use [`LengthList::try_from`] to construct values of this type.
|
2330 + | /// [constraint traits]. Use [`DateTimeSet::try_from`] to construct values of this type.
|
2886 2331 | ///
|
2887 2332 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2888 2333 | ///
|
2889 2334 | #[derive(
|
2890 2335 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2891 2336 | )]
|
2892 - | pub struct LengthList(pub(crate) ::std::vec::Vec<crate::model::LengthString>);
|
2893 - | impl LengthList {
|
2894 - | /// Returns an immutable reference to the underlying [`::std::vec::Vec<crate::model::LengthString>`].
|
2895 - | pub fn inner(&self) -> &::std::vec::Vec<crate::model::LengthString> {
|
2337 + | pub struct DateTimeSet(pub(crate) ::std::vec::Vec<::aws_smithy_types::DateTime>);
|
2338 + | impl DateTimeSet {
|
2339 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<::aws_smithy_types::DateTime>`].
|
2340 + | pub fn inner(&self) -> &::std::vec::Vec<::aws_smithy_types::DateTime> {
|
2896 2341 | &self.0
|
2897 2342 | }
|
2898 - | /// Consumes the value, returning the underlying [`::std::vec::Vec<crate::model::LengthString>`].
|
2899 - | pub fn into_inner(self) -> ::std::vec::Vec<crate::model::LengthString> {
|
2343 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<::aws_smithy_types::DateTime>`].
|
2344 + | pub fn into_inner(self) -> ::std::vec::Vec<::aws_smithy_types::DateTime> {
|
2900 2345 | self.0
|
2901 2346 | }
|
2902 2347 |
|
2903 - | fn check_length(
|
2904 - | length: usize,
|
2905 - | ) -> ::std::result::Result<(), crate::model::length_list::ConstraintViolation> {
|
2906 - | if (2..=8).contains(&length) {
|
2907 - | Ok(())
|
2348 + | fn check_unique_items(
|
2349 + | items: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
2350 + | ) -> ::std::result::Result<
|
2351 + | ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
2352 + | crate::model::date_time_set::ConstraintViolation,
|
2353 + | > {
|
2354 + | let mut seen = ::std::collections::HashMap::new();
|
2355 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
2356 + | for (idx, item) in items.iter().enumerate() {
|
2357 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
2358 + | duplicate_indices.push(prev_idx);
|
2359 + | }
|
2360 + | }
|
2361 + |
|
2362 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
2363 + | for idx in &duplicate_indices {
|
2364 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
2365 + | last_duplicate_indices.push(prev_idx);
|
2366 + | }
|
2367 + | }
|
2368 + | duplicate_indices.extend(last_duplicate_indices);
|
2369 + |
|
2370 + | if !duplicate_indices.is_empty() {
|
2371 + | debug_assert!(duplicate_indices.len() >= 2);
|
2372 + | Err(
|
2373 + | crate::model::date_time_set::ConstraintViolation::UniqueItems {
|
2374 + | duplicate_indices,
|
2375 + | original: items,
|
2376 + | },
|
2377 + | )
|
2908 2378 | } else {
|
2909 - | Err(crate::model::length_list::ConstraintViolation::Length(
|
2910 - | length,
|
2911 - | ))
|
2379 + | Ok(items)
|
2912 2380 | }
|
2913 2381 | }
|
2914 2382 | }
|
2915 - | impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::LengthString>> for LengthList {
|
2916 - | type Error = crate::model::length_list::ConstraintViolation;
|
2383 + | impl ::std::convert::TryFrom<::std::vec::Vec<::aws_smithy_types::DateTime>> for DateTimeSet {
|
2384 + | type Error = crate::model::date_time_set::ConstraintViolation;
|
2917 2385 |
|
2918 - | /// Constructs a `LengthList` from an [`::std::vec::Vec<crate::model::LengthString>`], failing when the provided value does not satisfy the modeled constraints.
|
2386 + | /// Constructs a `DateTimeSet` from an [`::std::vec::Vec<::aws_smithy_types::DateTime>`], failing when the provided value does not satisfy the modeled constraints.
|
2919 2387 | fn try_from(
|
2920 - | value: ::std::vec::Vec<crate::model::LengthString>,
|
2388 + | value: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
2921 2389 | ) -> ::std::result::Result<Self, Self::Error> {
|
2922 - | Self::check_length(value.len())?;
|
2390 + | let value = Self::check_unique_items(value)?;
|
2923 2391 |
|
2924 2392 | Ok(Self(value))
|
2925 2393 | }
|
2926 2394 | }
|
2927 2395 |
|
2928 - | impl ::std::convert::From<LengthList> for ::std::vec::Vec<crate::model::LengthString> {
|
2929 - | fn from(value: LengthList) -> Self {
|
2396 + | impl ::std::convert::From<DateTimeSet> for ::std::vec::Vec<::aws_smithy_types::DateTime> {
|
2397 + | fn from(value: DateTimeSet) -> Self {
|
2930 2398 | value.into_inner()
|
2931 2399 | }
|
2932 2400 | }
|
2933 - | impl crate::constrained::Constrained for LengthList {
|
2934 - | type Unconstrained = crate::unconstrained::length_list_unconstrained::LengthListUnconstrained;
|
2401 + | impl crate::constrained::Constrained for DateTimeSet {
|
2402 + | type Unconstrained =
|
2403 + | crate::unconstrained::date_time_set_unconstrained::DateTimeSetUnconstrained;
|
2935 2404 | }
|
2936 2405 |
|
2937 2406 | #[allow(missing_docs)] // documentation missing in model
|
2938 2407 | ///
|
2939 2408 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2940 - | /// [constraint traits]. Use [`LengthMap::try_from`] to construct values of this type.
|
2409 + | /// [constraint traits]. Use [`HttpDateSet::try_from`] to construct values of this type.
|
2941 2410 | ///
|
2942 2411 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2943 2412 | ///
|
2944 - | #[derive(::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug)]
|
2945 - | pub struct LengthMap(
|
2946 - | pub(crate) ::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>,
|
2947 - | );
|
2948 - | impl LengthMap {
|
2949 - | /// Returns an immutable reference to the underlying [`::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>`].
|
2950 - | pub fn inner(
|
2951 - | &self,
|
2952 - | ) -> &::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList> {
|
2413 + | #[derive(
|
2414 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2415 + | )]
|
2416 + | pub struct HttpDateSet(pub(crate) ::std::vec::Vec<::aws_smithy_types::DateTime>);
|
2417 + | impl HttpDateSet {
|
2418 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<::aws_smithy_types::DateTime>`].
|
2419 + | pub fn inner(&self) -> &::std::vec::Vec<::aws_smithy_types::DateTime> {
|
2953 2420 | &self.0
|
2954 2421 | }
|
2955 - | /// Consumes the value, returning the underlying [`::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>`].
|
2956 - | pub fn into_inner(
|
2957 - | self,
|
2958 - | ) -> ::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList> {
|
2422 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<::aws_smithy_types::DateTime>`].
|
2423 + | pub fn into_inner(self) -> ::std::vec::Vec<::aws_smithy_types::DateTime> {
|
2959 2424 | self.0
|
2960 2425 | }
|
2426 + |
|
2427 + | fn check_unique_items(
|
2428 + | items: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
2429 + | ) -> ::std::result::Result<
|
2430 + | ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
2431 + | crate::model::http_date_set::ConstraintViolation,
|
2432 + | > {
|
2433 + | let mut seen = ::std::collections::HashMap::new();
|
2434 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
2435 + | for (idx, item) in items.iter().enumerate() {
|
2436 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
2437 + | duplicate_indices.push(prev_idx);
|
2438 + | }
|
2439 + | }
|
2440 + |
|
2441 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
2442 + | for idx in &duplicate_indices {
|
2443 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
2444 + | last_duplicate_indices.push(prev_idx);
|
2445 + | }
|
2446 + | }
|
2447 + | duplicate_indices.extend(last_duplicate_indices);
|
2448 + |
|
2449 + | if !duplicate_indices.is_empty() {
|
2450 + | debug_assert!(duplicate_indices.len() >= 2);
|
2451 + | Err(
|
2452 + | crate::model::http_date_set::ConstraintViolation::UniqueItems {
|
2453 + | duplicate_indices,
|
2454 + | original: items,
|
2455 + | },
|
2456 + | )
|
2457 + | } else {
|
2458 + | Ok(items)
|
2459 + | }
|
2460 + | }
|
2961 2461 | }
|
2962 - | impl
|
2963 - | ::std::convert::TryFrom<
|
2964 - | ::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>,
|
2965 - | > for LengthMap
|
2966 - | {
|
2967 - | type Error = crate::model::length_map::ConstraintViolation;
|
2462 + | impl ::std::convert::TryFrom<::std::vec::Vec<::aws_smithy_types::DateTime>> for HttpDateSet {
|
2463 + | type Error = crate::model::http_date_set::ConstraintViolation;
|
2968 2464 |
|
2969 - | /// Constructs a `LengthMap` from an [`::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>`], failing when the provided value does not satisfy the modeled constraints.
|
2465 + | /// Constructs a `HttpDateSet` from an [`::std::vec::Vec<::aws_smithy_types::DateTime>`], failing when the provided value does not satisfy the modeled constraints.
|
2970 2466 | fn try_from(
|
2971 - | value: ::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>,
|
2467 + | value: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
2972 2468 | ) -> ::std::result::Result<Self, Self::Error> {
|
2973 - | let length = value.len();
|
2974 - | if (2..=8).contains(&length) {
|
2469 + | let value = Self::check_unique_items(value)?;
|
2470 + |
|
2975 2471 | Ok(Self(value))
|
2976 - | } else {
|
2977 - | Err(crate::model::length_map::ConstraintViolation::Length(
|
2978 - | length,
|
2979 - | ))
|
2980 - | }
|
2981 2472 | }
|
2982 2473 | }
|
2983 2474 |
|
2984 - | impl ::std::convert::From<LengthMap>
|
2985 - | for ::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>
|
2986 - | {
|
2987 - | fn from(value: LengthMap) -> Self {
|
2475 + | impl ::std::convert::From<HttpDateSet> for ::std::vec::Vec<::aws_smithy_types::DateTime> {
|
2476 + | fn from(value: HttpDateSet) -> Self {
|
2988 2477 | value.into_inner()
|
2989 2478 | }
|
2990 2479 | }
|
2991 - | impl crate::constrained::Constrained for LengthMap {
|
2992 - | type Unconstrained = crate::unconstrained::length_map_unconstrained::LengthMapUnconstrained;
|
2480 + | impl crate::constrained::Constrained for HttpDateSet {
|
2481 + | type Unconstrained =
|
2482 + | crate::unconstrained::http_date_set_unconstrained::HttpDateSetUnconstrained;
|
2993 2483 | }
|
2994 2484 |
|
2995 2485 | #[allow(missing_docs)] // documentation missing in model
|
2996 2486 | ///
|
2997 2487 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2998 - | /// [constraint traits]. Use [`MaxLengthString::try_from`] to construct values of this type.
|
2488 + | /// [constraint traits]. Use [`FooEnumSet::try_from`] to construct values of this type.
|
2999 2489 | ///
|
3000 2490 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
3001 2491 | ///
|
3002 2492 | #[derive(
|
3003 2493 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3004 2494 | )]
|
3005 - | pub struct MaxLengthString(pub(crate) ::std::string::String);
|
3006 - | impl MaxLengthString {
|
3007 - | /// Extracts a string slice containing the entire underlying `String`.
|
3008 - | pub fn as_str(&self) -> &str {
|
2495 + | pub struct FooEnumSet(pub(crate) ::std::vec::Vec<crate::model::FooEnum>);
|
2496 + | impl FooEnumSet {
|
2497 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<crate::model::FooEnum>`].
|
2498 + | pub fn inner(&self) -> &::std::vec::Vec<crate::model::FooEnum> {
|
3009 2499 | &self.0
|
3010 2500 | }
|
2501 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<crate::model::FooEnum>`].
|
2502 + | pub fn into_inner(self) -> ::std::vec::Vec<crate::model::FooEnum> {
|
2503 + | self.0
|
2504 + | }
|
3011 2505 |
|
3012 - | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
3013 - | pub fn inner(&self) -> &::std::string::String {
|
3014 - | &self.0
|
2506 + | fn check_unique_items(
|
2507 + | items: ::std::vec::Vec<crate::model::FooEnum>,
|
2508 + | ) -> ::std::result::Result<
|
2509 + | ::std::vec::Vec<crate::model::FooEnum>,
|
2510 + | crate::model::foo_enum_set::ConstraintViolation,
|
2511 + | > {
|
2512 + | let mut seen = ::std::collections::HashMap::new();
|
2513 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
2514 + | for (idx, item) in items.iter().enumerate() {
|
2515 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
2516 + | duplicate_indices.push(prev_idx);
|
2517 + | }
|
3015 2518 | }
|
3016 2519 |
|
3017 - | /// Consumes the value, returning the underlying [`::std::string::String`].
|
3018 - | pub fn into_inner(self) -> ::std::string::String {
|
3019 - | self.0
|
2520 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
2521 + | for idx in &duplicate_indices {
|
2522 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
2523 + | last_duplicate_indices.push(prev_idx);
|
3020 2524 | }
|
3021 - | }
|
3022 - | impl MaxLengthString {
|
3023 - | fn check_length(
|
3024 - | string: &str,
|
3025 - | ) -> ::std::result::Result<(), crate::model::max_length_string::ConstraintViolation> {
|
3026 - | let length = string.chars().count();
|
2525 + | }
|
2526 + | duplicate_indices.extend(last_duplicate_indices);
|
3027 2527 |
|
3028 - | if length <= 8 {
|
3029 - | Ok(())
|
2528 + | if !duplicate_indices.is_empty() {
|
2529 + | debug_assert!(duplicate_indices.len() >= 2);
|
2530 + | Err(
|
2531 + | crate::model::foo_enum_set::ConstraintViolation::UniqueItems {
|
2532 + | duplicate_indices,
|
2533 + | original: items,
|
2534 + | },
|
2535 + | )
|
3030 2536 | } else {
|
3031 - | Err(crate::model::max_length_string::ConstraintViolation::Length(length))
|
2537 + | Ok(items)
|
3032 2538 | }
|
3033 2539 | }
|
3034 2540 | }
|
3035 - | impl ::std::convert::TryFrom<::std::string::String> for MaxLengthString {
|
3036 - | type Error = crate::model::max_length_string::ConstraintViolation;
|
2541 + | impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::FooEnum>> for FooEnumSet {
|
2542 + | type Error = crate::model::foo_enum_set::ConstraintViolation;
|
3037 2543 |
|
3038 - | /// Constructs a `MaxLengthString` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
3039 - | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
3040 - | Self::check_length(&value)?;
|
2544 + | /// Constructs a `FooEnumSet` from an [`::std::vec::Vec<crate::model::FooEnum>`], failing when the provided value does not satisfy the modeled constraints.
|
2545 + | fn try_from(
|
2546 + | value: ::std::vec::Vec<crate::model::FooEnum>,
|
2547 + | ) -> ::std::result::Result<Self, Self::Error> {
|
2548 + | let value = Self::check_unique_items(value)?;
|
3041 2549 |
|
3042 2550 | Ok(Self(value))
|
3043 2551 | }
|
3044 2552 | }
|
3045 - | impl crate::constrained::Constrained for MaxLengthString {
|
3046 - | type Unconstrained = ::std::string::String;
|
3047 - | }
|
3048 2553 |
|
3049 - | impl ::std::convert::From<::std::string::String>
|
3050 - | for crate::constrained::MaybeConstrained<crate::model::MaxLengthString>
|
3051 - | {
|
3052 - | fn from(value: ::std::string::String) -> Self {
|
3053 - | Self::Unconstrained(value)
|
2554 + | impl ::std::convert::From<FooEnumSet> for ::std::vec::Vec<crate::model::FooEnum> {
|
2555 + | fn from(value: FooEnumSet) -> Self {
|
2556 + | value.into_inner()
|
3054 2557 | }
|
3055 2558 | }
|
3056 - |
|
3057 - | impl ::std::fmt::Display for MaxLengthString {
|
3058 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3059 - | self.0.fmt(f)
|
3060 - | }
|
3061 - | }
|
3062 - |
|
3063 - | impl ::std::convert::From<MaxLengthString> for ::std::string::String {
|
3064 - | fn from(value: MaxLengthString) -> Self {
|
3065 - | value.into_inner()
|
3066 - | }
|
2559 + | impl crate::constrained::Constrained for FooEnumSet {
|
2560 + | type Unconstrained = crate::unconstrained::foo_enum_set_unconstrained::FooEnumSetUnconstrained;
|
3067 2561 | }
|
3068 2562 |
|
3069 2563 | #[allow(missing_docs)] // documentation missing in model
|
3070 2564 | ///
|
3071 2565 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
3072 - | /// [constraint traits]. Use [`MinLengthString::try_from`] to construct values of this type.
|
2566 + | /// [constraint traits]. Use [`IntegerEnumSet::try_from`] to construct values of this type.
|
3073 2567 | ///
|
3074 2568 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
3075 2569 | ///
|
3076 2570 | #[derive(
|
3077 2571 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3078 2572 | )]
|
3079 - | pub struct MinLengthString(pub(crate) ::std::string::String);
|
3080 - | impl MinLengthString {
|
3081 - | /// Extracts a string slice containing the entire underlying `String`.
|
3082 - | pub fn as_str(&self) -> &str {
|
2573 + | pub struct IntegerEnumSet(pub(crate) ::std::vec::Vec<i32>);
|
2574 + | impl IntegerEnumSet {
|
2575 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<i32>`].
|
2576 + | pub fn inner(&self) -> &::std::vec::Vec<i32> {
|
3083 2577 | &self.0
|
3084 2578 | }
|
2579 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<i32>`].
|
2580 + | pub fn into_inner(self) -> ::std::vec::Vec<i32> {
|
2581 + | self.0
|
2582 + | }
|
3085 2583 |
|
3086 - | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
3087 - | pub fn inner(&self) -> &::std::string::String {
|
3088 - | &self.0
|
2584 + | fn check_unique_items(
|
2585 + | items: ::std::vec::Vec<i32>,
|
2586 + | ) -> ::std::result::Result<
|
2587 + | ::std::vec::Vec<i32>,
|
2588 + | crate::model::integer_enum_set::ConstraintViolation,
|
2589 + | > {
|
2590 + | let mut seen = ::std::collections::HashMap::new();
|
2591 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
2592 + | for (idx, item) in items.iter().enumerate() {
|
2593 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
2594 + | duplicate_indices.push(prev_idx);
|
2595 + | }
|
3089 2596 | }
|
3090 2597 |
|
3091 - | /// Consumes the value, returning the underlying [`::std::string::String`].
|
3092 - | pub fn into_inner(self) -> ::std::string::String {
|
3093 - | self.0
|
2598 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
2599 + | for idx in &duplicate_indices {
|
2600 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
2601 + | last_duplicate_indices.push(prev_idx);
|
3094 2602 | }
|
3095 - | }
|
3096 - | impl MinLengthString {
|
3097 - | fn check_length(
|
3098 - | string: &str,
|
3099 - | ) -> ::std::result::Result<(), crate::model::min_length_string::ConstraintViolation> {
|
3100 - | let length = string.chars().count();
|
2603 + | }
|
2604 + | duplicate_indices.extend(last_duplicate_indices);
|
3101 2605 |
|
3102 - | if 2 <= length {
|
3103 - | Ok(())
|
2606 + | if !duplicate_indices.is_empty() {
|
2607 + | debug_assert!(duplicate_indices.len() >= 2);
|
2608 + | Err(
|
2609 + | crate::model::integer_enum_set::ConstraintViolation::UniqueItems {
|
2610 + | duplicate_indices,
|
2611 + | original: items,
|
2612 + | },
|
2613 + | )
|
3104 2614 | } else {
|
3105 - | Err(crate::model::min_length_string::ConstraintViolation::Length(length))
|
2615 + | Ok(items)
|
3106 2616 | }
|
3107 2617 | }
|
3108 2618 | }
|
3109 - | impl ::std::convert::TryFrom<::std::string::String> for MinLengthString {
|
3110 - | type Error = crate::model::min_length_string::ConstraintViolation;
|
2619 + | impl ::std::convert::TryFrom<::std::vec::Vec<i32>> for IntegerEnumSet {
|
2620 + | type Error = crate::model::integer_enum_set::ConstraintViolation;
|
3111 2621 |
|
3112 - | /// Constructs a `MinLengthString` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
3113 - | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
3114 - | Self::check_length(&value)?;
|
2622 + | /// Constructs a `IntegerEnumSet` from an [`::std::vec::Vec<i32>`], failing when the provided value does not satisfy the modeled constraints.
|
2623 + | fn try_from(value: ::std::vec::Vec<i32>) -> ::std::result::Result<Self, Self::Error> {
|
2624 + | let value = Self::check_unique_items(value)?;
|
3115 2625 |
|
3116 2626 | Ok(Self(value))
|
3117 2627 | }
|
3118 2628 | }
|
3119 - | impl crate::constrained::Constrained for MinLengthString {
|
3120 - | type Unconstrained = ::std::string::String;
|
3121 - | }
|
3122 - |
|
3123 - | impl ::std::convert::From<::std::string::String>
|
3124 - | for crate::constrained::MaybeConstrained<crate::model::MinLengthString>
|
3125 - | {
|
3126 - | fn from(value: ::std::string::String) -> Self {
|
3127 - | Self::Unconstrained(value)
|
3128 - | }
|
3129 - | }
|
3130 - |
|
3131 - | impl ::std::fmt::Display for MinLengthString {
|
3132 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3133 - | self.0.fmt(f)
|
3134 - | }
|
3135 - | }
|
3136 2629 |
|
3137 - | impl ::std::convert::From<MinLengthString> for ::std::string::String {
|
3138 - | fn from(value: MinLengthString) -> Self {
|
2630 + | impl ::std::convert::From<IntegerEnumSet> for ::std::vec::Vec<i32> {
|
2631 + | fn from(value: IntegerEnumSet) -> Self {
|
3139 2632 | value.into_inner()
|
3140 2633 | }
|
3141 2634 | }
|
2635 + | impl crate::constrained::Constrained for IntegerEnumSet {
|
2636 + | type Unconstrained =
|
2637 + | crate::unconstrained::integer_enum_set_unconstrained::IntegerEnumSetUnconstrained;
|
2638 + | }
|
3142 2639 |
|
3143 2640 | #[allow(missing_docs)] // documentation missing in model
|
3144 2641 | ///
|
3145 2642 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
3146 - | /// [constraint traits]. Use [`LengthBlob::try_from`] to construct values of this type.
|
2643 + | /// [constraint traits]. Use [`ListSet::try_from`] to construct values of this type.
|
3147 2644 | ///
|
3148 2645 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
3149 2646 | ///
|
3150 2647 | #[derive(
|
3151 2648 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3152 2649 | )]
|
3153 - | pub struct LengthBlob(pub(crate) ::aws_smithy_types::Blob);
|
3154 - | impl LengthBlob {
|
3155 - | /// Returns an immutable reference to the underlying [`::aws_smithy_types::Blob`].
|
3156 - | pub fn inner(&self) -> &::aws_smithy_types::Blob {
|
2650 + | pub struct ListSet(pub(crate) ::std::vec::Vec<::std::vec::Vec<::std::string::String>>);
|
2651 + | impl ListSet {
|
2652 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<::std::vec::Vec::<::std::string::String>>`].
|
2653 + | pub fn inner(&self) -> &::std::vec::Vec<::std::vec::Vec<::std::string::String>> {
|
3157 2654 | &self.0
|
3158 2655 | }
|
3159 - | /// Consumes the value, returning the underlying [`::aws_smithy_types::Blob`].
|
3160 - | pub fn into_inner(self) -> ::aws_smithy_types::Blob {
|
2656 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<::std::vec::Vec::<::std::string::String>>`].
|
2657 + | pub fn into_inner(self) -> ::std::vec::Vec<::std::vec::Vec<::std::string::String>> {
|
3161 2658 | self.0
|
3162 2659 | }
|
3163 - | }
|
3164 - | impl LengthBlob {
|
3165 - | fn check_length(
|
3166 - | blob: &::aws_smithy_types::Blob,
|
3167 - | ) -> ::std::result::Result<(), crate::model::length_blob::ConstraintViolation> {
|
3168 - | let length = blob.as_ref().len();
|
3169 2660 |
|
3170 - | if (2..=8).contains(&length) {
|
3171 - | Ok(())
|
3172 - | } else {
|
3173 - | Err(crate::model::length_blob::ConstraintViolation::Length(
|
3174 - | length,
|
3175 - | ))
|
2661 + | fn check_unique_items(
|
2662 + | items: ::std::vec::Vec<::std::vec::Vec<::std::string::String>>,
|
2663 + | ) -> ::std::result::Result<
|
2664 + | ::std::vec::Vec<::std::vec::Vec<::std::string::String>>,
|
2665 + | crate::model::list_set::ConstraintViolation,
|
2666 + | > {
|
2667 + | let mut seen = ::std::collections::HashMap::new();
|
2668 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
2669 + | for (idx, item) in items.iter().enumerate() {
|
2670 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
2671 + | duplicate_indices.push(prev_idx);
|
3176 2672 | }
|
3177 2673 | }
|
3178 - | }
|
3179 - | impl ::std::convert::TryFrom<::aws_smithy_types::Blob> for LengthBlob {
|
3180 - | type Error = crate::model::length_blob::ConstraintViolation;
|
3181 2674 |
|
3182 - | /// Constructs a `LengthBlob` from an [`::aws_smithy_types::Blob`], failing when the provided value does not satisfy the modeled constraints.
|
3183 - | fn try_from(value: ::aws_smithy_types::Blob) -> ::std::result::Result<Self, Self::Error> {
|
3184 - | Self::check_length(&value)?;
|
2675 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
2676 + | for idx in &duplicate_indices {
|
2677 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
2678 + | last_duplicate_indices.push(prev_idx);
|
2679 + | }
|
2680 + | }
|
2681 + | duplicate_indices.extend(last_duplicate_indices);
|
3185 2682 |
|
3186 - | Ok(Self(value))
|
2683 + | if !duplicate_indices.is_empty() {
|
2684 + | debug_assert!(duplicate_indices.len() >= 2);
|
2685 + | Err(crate::model::list_set::ConstraintViolation::UniqueItems {
|
2686 + | duplicate_indices,
|
2687 + | original: items,
|
2688 + | })
|
2689 + | } else {
|
2690 + | Ok(items)
|
2691 + | }
|
3187 2692 | }
|
3188 2693 | }
|
3189 - | impl crate::constrained::Constrained for LengthBlob {
|
3190 - | type Unconstrained = ::aws_smithy_types::Blob;
|
3191 - | }
|
2694 + | impl ::std::convert::TryFrom<::std::vec::Vec<::std::vec::Vec<::std::string::String>>> for ListSet {
|
2695 + | type Error = crate::model::list_set::ConstraintViolation;
|
3192 2696 |
|
3193 - | impl ::std::convert::From<::aws_smithy_types::Blob>
|
3194 - | for crate::constrained::MaybeConstrained<crate::model::LengthBlob>
|
3195 - | {
|
3196 - | fn from(value: ::aws_smithy_types::Blob) -> Self {
|
3197 - | Self::Unconstrained(value)
|
2697 + | /// Constructs a `ListSet` from an [`::std::vec::Vec<::std::vec::Vec::<::std::string::String>>`], failing when the provided value does not satisfy the modeled constraints.
|
2698 + | fn try_from(
|
2699 + | value: ::std::vec::Vec<::std::vec::Vec<::std::string::String>>,
|
2700 + | ) -> ::std::result::Result<Self, Self::Error> {
|
2701 + | let value = Self::check_unique_items(value)?;
|
2702 + |
|
2703 + | Ok(Self(value))
|
3198 2704 | }
|
3199 2705 | }
|
3200 2706 |
|
3201 - | impl ::std::convert::From<LengthBlob> for ::aws_smithy_types::Blob {
|
3202 - | fn from(value: LengthBlob) -> Self {
|
2707 + | impl ::std::convert::From<ListSet> for ::std::vec::Vec<::std::vec::Vec<::std::string::String>> {
|
2708 + | fn from(value: ListSet) -> Self {
|
3203 2709 | value.into_inner()
|
3204 2710 | }
|
3205 2711 | }
|
2712 + | impl crate::constrained::Constrained for ListSet {
|
2713 + | type Unconstrained = crate::unconstrained::list_set_unconstrained::ListSetUnconstrained;
|
2714 + | }
|
3206 2715 |
|
3207 2716 | #[allow(missing_docs)] // documentation missing in model
|
2717 + | ///
|
2718 + | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2719 + | /// [constraint traits]. Use [`StructureSet::try_from`] to construct values of this type.
|
2720 + | ///
|
2721 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2722 + | ///
|
3208 2723 | #[derive(
|
3209 2724 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3210 2725 | )]
|
3211 - | pub enum EnumUnion {
|
3212 - | #[allow(missing_docs)] // documentation missing in model
|
3213 - | First(crate::model::EnumString),
|
3214 - | #[allow(missing_docs)] // documentation missing in model
|
3215 - | Second(crate::model::EnumString),
|
3216 - | }
|
3217 - | impl EnumUnion {
|
3218 - | /// Tries to convert the enum instance into [`First`](crate::model::EnumUnion::First), extracting the inner [`EnumString`](crate::model::EnumString).
|
3219 - | /// Returns `Err(&Self)` if it can't be converted.
|
3220 - | pub fn as_first(&self) -> ::std::result::Result<&crate::model::EnumString, &Self> {
|
3221 - | if let EnumUnion::First(val) = &self {
|
3222 - | ::std::result::Result::Ok(val)
|
3223 - | } else {
|
3224 - | ::std::result::Result::Err(self)
|
2726 + | pub struct StructureSet(pub(crate) ::std::vec::Vec<crate::model::GreetingStruct>);
|
2727 + | impl StructureSet {
|
2728 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<crate::model::GreetingStruct>`].
|
2729 + | pub fn inner(&self) -> &::std::vec::Vec<crate::model::GreetingStruct> {
|
2730 + | &self.0
|
3225 2731 | }
|
2732 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<crate::model::GreetingStruct>`].
|
2733 + | pub fn into_inner(self) -> ::std::vec::Vec<crate::model::GreetingStruct> {
|
2734 + | self.0
|
3226 2735 | }
|
3227 - | /// Returns true if this is a [`First`](crate::model::EnumUnion::First).
|
3228 - | pub fn is_first(&self) -> bool {
|
3229 - | self.as_first().is_ok()
|
2736 + |
|
2737 + | fn check_unique_items(
|
2738 + | items: ::std::vec::Vec<crate::model::GreetingStruct>,
|
2739 + | ) -> ::std::result::Result<
|
2740 + | ::std::vec::Vec<crate::model::GreetingStruct>,
|
2741 + | crate::model::structure_set::ConstraintViolation,
|
2742 + | > {
|
2743 + | let mut seen = ::std::collections::HashMap::new();
|
2744 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
2745 + | for (idx, item) in items.iter().enumerate() {
|
2746 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
2747 + | duplicate_indices.push(prev_idx);
|
3230 2748 | }
|
3231 - | /// Tries to convert the enum instance into [`Second`](crate::model::EnumUnion::Second), extracting the inner [`EnumString`](crate::model::EnumString).
|
3232 - | /// Returns `Err(&Self)` if it can't be converted.
|
3233 - | pub fn as_second(&self) -> ::std::result::Result<&crate::model::EnumString, &Self> {
|
3234 - | if let EnumUnion::Second(val) = &self {
|
3235 - | ::std::result::Result::Ok(val)
|
3236 - | } else {
|
3237 - | ::std::result::Result::Err(self)
|
3238 2749 | }
|
2750 + |
|
2751 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
2752 + | for idx in &duplicate_indices {
|
2753 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
2754 + | last_duplicate_indices.push(prev_idx);
|
3239 2755 | }
|
3240 - | /// Returns true if this is a [`Second`](crate::model::EnumUnion::Second).
|
3241 - | pub fn is_second(&self) -> bool {
|
3242 - | self.as_second().is_ok()
|
3243 2756 | }
|
3244 - | }
|
2757 + | duplicate_indices.extend(last_duplicate_indices);
|
3245 2758 |
|
3246 - | #[allow(missing_docs)] // documentation missing in model
|
3247 - | #[derive(
|
3248 - | ::std::clone::Clone,
|
3249 - | ::std::cmp::Eq,
|
3250 - | ::std::cmp::Ord,
|
3251 - | ::std::cmp::PartialEq,
|
3252 - | ::std::cmp::PartialOrd,
|
3253 - | ::std::fmt::Debug,
|
3254 - | ::std::hash::Hash,
|
3255 - | )]
|
3256 - | pub enum EnumString {
|
3257 - | #[allow(missing_docs)] // documentation missing in model
|
3258 - | Abc,
|
3259 - | #[allow(missing_docs)] // documentation missing in model
|
3260 - | Def,
|
3261 - | #[allow(missing_docs)] // documentation missing in model
|
3262 - | Ghi,
|
3263 - | #[allow(missing_docs)] // documentation missing in model
|
3264 - | Jkl,
|
3265 - | }
|
3266 - | /// See [`EnumString`](crate::model::EnumString).
|
3267 - | pub mod enum_string {
|
3268 - | #[derive(Debug, PartialEq)]
|
3269 - | pub struct ConstraintViolation(pub(crate) ::std::string::String);
|
3270 - |
|
3271 - | impl ::std::fmt::Display for ConstraintViolation {
|
3272 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3273 - | write!(
|
3274 - | f,
|
3275 - | r#"Value provided for 'aws.protocoltests.restjson.validation#EnumString' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, ghi, jkl]"#
|
2759 + | if !duplicate_indices.is_empty() {
|
2760 + | debug_assert!(duplicate_indices.len() >= 2);
|
2761 + | Err(
|
2762 + | crate::model::structure_set::ConstraintViolation::UniqueItems {
|
2763 + | duplicate_indices,
|
2764 + | original: items,
|
2765 + | },
|
3276 2766 | )
|
2767 + | } else {
|
2768 + | Ok(items)
|
3277 2769 | }
|
3278 2770 | }
|
2771 + | }
|
2772 + | impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::GreetingStruct>> for StructureSet {
|
2773 + | type Error = crate::model::structure_set::ConstraintViolation;
|
3279 2774 |
|
3280 - | impl ::std::error::Error for ConstraintViolation {}
|
3281 - | impl ConstraintViolation {
|
3282 - | pub(crate) fn as_validation_exception_field(
|
3283 - | self,
|
3284 - | path: ::std::string::String,
|
3285 - | ) -> crate::model::ValidationExceptionField {
|
3286 - | crate::model::ValidationExceptionField {
|
3287 - | message: format!(
|
3288 - | r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, ghi, jkl]"#,
|
3289 - | &path
|
3290 - | ),
|
3291 - | path,
|
3292 - | }
|
2775 + | /// Constructs a `StructureSet` from an [`::std::vec::Vec<crate::model::GreetingStruct>`], failing when the provided value does not satisfy the modeled constraints.
|
2776 + | fn try_from(
|
2777 + | value: ::std::vec::Vec<crate::model::GreetingStruct>,
|
2778 + | ) -> ::std::result::Result<Self, Self::Error> {
|
2779 + | let value = Self::check_unique_items(value)?;
|
2780 + |
|
2781 + | Ok(Self(value))
|
3293 2782 | }
|
2783 + | }
|
2784 + |
|
2785 + | impl ::std::convert::From<StructureSet> for ::std::vec::Vec<crate::model::GreetingStruct> {
|
2786 + | fn from(value: StructureSet) -> Self {
|
2787 + | value.into_inner()
|
3294 2788 | }
|
3295 2789 | }
|
3296 - | impl ::std::convert::TryFrom<&str> for EnumString {
|
3297 - | type Error = crate::model::enum_string::ConstraintViolation;
|
3298 - | fn try_from(
|
3299 - | s: &str,
|
3300 - | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<&str>>::Error> {
|
3301 - | match s {
|
3302 - | "abc" => Ok(EnumString::Abc),
|
3303 - | "def" => Ok(EnumString::Def),
|
3304 - | "ghi" => Ok(EnumString::Ghi),
|
3305 - | "jkl" => Ok(EnumString::Jkl),
|
3306 - | _ => Err(crate::model::enum_string::ConstraintViolation(s.to_owned())),
|
2790 + | impl crate::constrained::Constrained for StructureSet {
|
2791 + | type Unconstrained =
|
2792 + | crate::unconstrained::structure_set_unconstrained::StructureSetUnconstrained;
|
2793 + | }
|
2794 + |
|
2795 + | #[allow(missing_docs)] // documentation missing in model
|
2796 + | ///
|
2797 + | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2798 + | /// [constraint traits]. Use [`StructureSetWithNoKey::try_from`] to construct values of this type.
|
2799 + | ///
|
2800 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2801 + | ///
|
2802 + | #[derive(
|
2803 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2804 + | )]
|
2805 + | pub struct StructureSetWithNoKey(pub(crate) ::std::vec::Vec<crate::model::MissingKeyStructure>);
|
2806 + | impl StructureSetWithNoKey {
|
2807 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<crate::model::MissingKeyStructure>`].
|
2808 + | pub fn inner(&self) -> &::std::vec::Vec<crate::model::MissingKeyStructure> {
|
2809 + | &self.0
|
3307 2810 | }
|
2811 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<crate::model::MissingKeyStructure>`].
|
2812 + | pub fn into_inner(self) -> ::std::vec::Vec<crate::model::MissingKeyStructure> {
|
2813 + | self.0
|
3308 2814 | }
|
3309 - | }
|
3310 - | impl ::std::convert::TryFrom<::std::string::String> for EnumString {
|
3311 - | type Error = crate::model::enum_string::ConstraintViolation;
|
3312 - | fn try_from(
|
3313 - | s: ::std::string::String,
|
3314 - | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<::std::string::String>>::Error>
|
3315 - | {
|
3316 - | s.as_str().try_into()
|
2815 + |
|
2816 + | fn check_unique_items(
|
2817 + | items: ::std::vec::Vec<crate::model::MissingKeyStructure>,
|
2818 + | ) -> ::std::result::Result<
|
2819 + | ::std::vec::Vec<crate::model::MissingKeyStructure>,
|
2820 + | crate::model::structure_set_with_no_key::ConstraintViolation,
|
2821 + | > {
|
2822 + | let mut seen = ::std::collections::HashMap::new();
|
2823 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
2824 + | for (idx, item) in items.iter().enumerate() {
|
2825 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
2826 + | duplicate_indices.push(prev_idx);
|
3317 2827 | }
|
3318 - | }
|
3319 - | impl std::str::FromStr for EnumString {
|
3320 - | type Err = crate::model::enum_string::ConstraintViolation;
|
3321 - | fn from_str(s: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
|
3322 - | Self::try_from(s)
|
3323 2828 | }
|
3324 - | }
|
3325 - | impl EnumString {
|
3326 - | /// Returns the `&str` value of the enum member.
|
3327 - | pub fn as_str(&self) -> &str {
|
3328 - | match self {
|
3329 - | EnumString::Abc => "abc",
|
3330 - | EnumString::Def => "def",
|
3331 - | EnumString::Ghi => "ghi",
|
3332 - | EnumString::Jkl => "jkl",
|
2829 + |
|
2830 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
2831 + | for idx in &duplicate_indices {
|
2832 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
2833 + | last_duplicate_indices.push(prev_idx);
|
3333 2834 | }
|
3334 2835 | }
|
3335 - | /// Returns all the `&str` representations of the enum members.
|
3336 - | pub const fn values() -> &'static [&'static str] {
|
3337 - | &["abc", "def", "ghi", "jkl"]
|
2836 + | duplicate_indices.extend(last_duplicate_indices);
|
2837 + |
|
2838 + | if !duplicate_indices.is_empty() {
|
2839 + | debug_assert!(duplicate_indices.len() >= 2);
|
2840 + | Err(
|
2841 + | crate::model::structure_set_with_no_key::ConstraintViolation::UniqueItems {
|
2842 + | duplicate_indices,
|
2843 + | original: items,
|
2844 + | },
|
2845 + | )
|
2846 + | } else {
|
2847 + | Ok(items)
|
3338 2848 | }
|
3339 - | }
|
3340 - | impl ::std::convert::AsRef<str> for EnumString {
|
3341 - | fn as_ref(&self) -> &str {
|
3342 - | self.as_str()
|
3343 2849 | }
|
3344 2850 | }
|
3345 - | impl crate::constrained::Constrained for EnumString {
|
3346 - | type Unconstrained = ::std::string::String;
|
2851 + | impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::MissingKeyStructure>>
|
2852 + | for StructureSetWithNoKey
|
2853 + | {
|
2854 + | type Error = crate::model::structure_set_with_no_key::ConstraintViolation;
|
2855 + |
|
2856 + | /// Constructs a `StructureSetWithNoKey` from an [`::std::vec::Vec<crate::model::MissingKeyStructure>`], failing when the provided value does not satisfy the modeled constraints.
|
2857 + | fn try_from(
|
2858 + | value: ::std::vec::Vec<crate::model::MissingKeyStructure>,
|
2859 + | ) -> ::std::result::Result<Self, Self::Error> {
|
2860 + | let value = Self::check_unique_items(value)?;
|
2861 + |
|
2862 + | Ok(Self(value))
|
2863 + | }
|
3347 2864 | }
|
3348 2865 |
|
3349 - | impl ::std::convert::From<::std::string::String>
|
3350 - | for crate::constrained::MaybeConstrained<crate::model::EnumString>
|
2866 + | impl ::std::convert::From<StructureSetWithNoKey>
|
2867 + | for ::std::vec::Vec<crate::model::MissingKeyStructure>
|
3351 2868 | {
|
3352 - | fn from(value: ::std::string::String) -> Self {
|
3353 - | Self::Unconstrained(value)
|
2869 + | fn from(value: StructureSetWithNoKey) -> Self {
|
2870 + | value.into_inner()
|
3354 2871 | }
|
3355 2872 | }
|
2873 + | impl crate::constrained::Constrained for StructureSetWithNoKey {
|
2874 + | type Unconstrained = crate::unconstrained::structure_set_with_no_key_unconstrained::StructureSetWithNoKeyUnconstrained;
|
2875 + | }
|
3356 2876 |
|
3357 2877 | #[allow(missing_docs)] // documentation missing in model
|
2878 + | ///
|
2879 + | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2880 + | /// [constraint traits]. Use [`UnionSet::try_from`] to construct values of this type.
|
2881 + | ///
|
2882 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2883 + | ///
|
3358 2884 | #[derive(
|
3359 - | ::std::clone::Clone,
|
3360 - | ::std::cmp::Eq,
|
3361 - | ::std::cmp::Ord,
|
3362 - | ::std::cmp::PartialEq,
|
3363 - | ::std::cmp::PartialOrd,
|
3364 - | ::std::fmt::Debug,
|
3365 - | ::std::hash::Hash,
|
2885 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3366 2886 | )]
|
3367 - | pub enum EnumTraitString {
|
3368 - | #[allow(missing_docs)] // documentation missing in model
|
3369 - | Abc,
|
3370 - | #[allow(missing_docs)] // documentation missing in model
|
3371 - | Def,
|
3372 - | #[allow(missing_docs)] // documentation missing in model
|
3373 - | Ghi,
|
3374 - | }
|
3375 - | /// See [`EnumTraitString`](crate::model::EnumTraitString).
|
3376 - | pub mod enum_trait_string {
|
3377 - | #[derive(Debug, PartialEq)]
|
3378 - | pub struct ConstraintViolation(pub(crate) ::std::string::String);
|
2887 + | pub struct UnionSet(pub(crate) ::std::vec::Vec<crate::model::FooUnion>);
|
2888 + | impl UnionSet {
|
2889 + | /// Returns an immutable reference to the underlying [`::std::vec::Vec<crate::model::FooUnion>`].
|
2890 + | pub fn inner(&self) -> &::std::vec::Vec<crate::model::FooUnion> {
|
2891 + | &self.0
|
2892 + | }
|
2893 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<crate::model::FooUnion>`].
|
2894 + | pub fn into_inner(self) -> ::std::vec::Vec<crate::model::FooUnion> {
|
2895 + | self.0
|
2896 + | }
|
3379 2897 |
|
3380 - | impl ::std::fmt::Display for ConstraintViolation {
|
3381 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3382 - | write!(
|
3383 - | f,
|
3384 - | r#"Value provided for 'aws.protocoltests.restjson.validation#EnumTraitString' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, ghi]"#
|
3385 - | )
|
2898 + | fn check_unique_items(
|
2899 + | items: ::std::vec::Vec<crate::model::FooUnion>,
|
2900 + | ) -> ::std::result::Result<
|
2901 + | ::std::vec::Vec<crate::model::FooUnion>,
|
2902 + | crate::model::union_set::ConstraintViolation,
|
2903 + | > {
|
2904 + | let mut seen = ::std::collections::HashMap::new();
|
2905 + | let mut duplicate_indices = ::std::vec::Vec::new();
|
2906 + | for (idx, item) in items.iter().enumerate() {
|
2907 + | if let Some(prev_idx) = seen.insert(item, idx) {
|
2908 + | duplicate_indices.push(prev_idx);
|
3386 2909 | }
|
3387 2910 | }
|
3388 2911 |
|
3389 - | impl ::std::error::Error for ConstraintViolation {}
|
3390 - | impl ConstraintViolation {
|
3391 - | pub(crate) fn as_validation_exception_field(
|
3392 - | self,
|
3393 - | path: ::std::string::String,
|
3394 - | ) -> crate::model::ValidationExceptionField {
|
3395 - | crate::model::ValidationExceptionField {
|
3396 - | message: format!(
|
3397 - | r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [abc, def, ghi]"#,
|
3398 - | &path
|
3399 - | ),
|
3400 - | path,
|
2912 + | let mut last_duplicate_indices = ::std::vec::Vec::new();
|
2913 + | for idx in &duplicate_indices {
|
2914 + | if let Some(prev_idx) = seen.remove(&items[*idx]) {
|
2915 + | last_duplicate_indices.push(prev_idx);
|
2916 + | }
|
3401 2917 | }
|
2918 + | duplicate_indices.extend(last_duplicate_indices);
|
2919 + |
|
2920 + | if !duplicate_indices.is_empty() {
|
2921 + | debug_assert!(duplicate_indices.len() >= 2);
|
2922 + | Err(crate::model::union_set::ConstraintViolation::UniqueItems {
|
2923 + | duplicate_indices,
|
2924 + | original: items,
|
2925 + | })
|
2926 + | } else {
|
2927 + | Ok(items)
|
3402 2928 | }
|
3403 2929 | }
|
3404 2930 | }
|
3405 - | impl ::std::convert::TryFrom<&str> for EnumTraitString {
|
3406 - | type Error = crate::model::enum_trait_string::ConstraintViolation;
|
2931 + | impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::FooUnion>> for UnionSet {
|
2932 + | type Error = crate::model::union_set::ConstraintViolation;
|
2933 + |
|
2934 + | /// Constructs a `UnionSet` from an [`::std::vec::Vec<crate::model::FooUnion>`], failing when the provided value does not satisfy the modeled constraints.
|
3407 2935 | fn try_from(
|
3408 - | s: &str,
|
3409 - | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<&str>>::Error> {
|
3410 - | match s {
|
3411 - | "abc" => Ok(EnumTraitString::Abc),
|
3412 - | "def" => Ok(EnumTraitString::Def),
|
3413 - | "ghi" => Ok(EnumTraitString::Ghi),
|
3414 - | _ => Err(crate::model::enum_trait_string::ConstraintViolation(
|
3415 - | s.to_owned(),
|
3416 - | )),
|
3417 - | }
|
2936 + | value: ::std::vec::Vec<crate::model::FooUnion>,
|
2937 + | ) -> ::std::result::Result<Self, Self::Error> {
|
2938 + | let value = Self::check_unique_items(value)?;
|
2939 + |
|
2940 + | Ok(Self(value))
|
3418 2941 | }
|
3419 2942 | }
|
3420 - | impl ::std::convert::TryFrom<::std::string::String> for EnumTraitString {
|
3421 - | type Error = crate::model::enum_trait_string::ConstraintViolation;
|
3422 - | fn try_from(
|
3423 - | s: ::std::string::String,
|
3424 - | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<::std::string::String>>::Error>
|
3425 - | {
|
3426 - | s.as_str().try_into()
|
2943 + |
|
2944 + | impl ::std::convert::From<UnionSet> for ::std::vec::Vec<crate::model::FooUnion> {
|
2945 + | fn from(value: UnionSet) -> Self {
|
2946 + | value.into_inner()
|
3427 2947 | }
|
3428 2948 | }
|
3429 - | impl std::str::FromStr for EnumTraitString {
|
3430 - | type Err = crate::model::enum_trait_string::ConstraintViolation;
|
3431 - | fn from_str(s: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
|
3432 - | Self::try_from(s)
|
2949 + | impl crate::constrained::Constrained for UnionSet {
|
2950 + | type Unconstrained = crate::unconstrained::union_set_unconstrained::UnionSetUnconstrained;
|
2951 + | }
|
2952 + |
|
2953 + | #[allow(missing_docs)] // documentation missing in model
|
2954 + | #[derive(
|
2955 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2956 + | )]
|
2957 + | pub enum RecursiveUnionOne {
|
2958 + | #[allow(missing_docs)] // documentation missing in model
|
2959 + | String(crate::model::RecursiveEnumString),
|
2960 + | #[allow(missing_docs)] // documentation missing in model
|
2961 + | Union(::std::boxed::Box<crate::model::RecursiveUnionTwo>),
|
2962 + | }
|
2963 + | impl RecursiveUnionOne {
|
2964 + | /// Tries to convert the enum instance into [`String`](crate::model::RecursiveUnionOne::String), extracting the inner [`RecursiveEnumString`](crate::model::RecursiveEnumString).
|
2965 + | /// Returns `Err(&Self)` if it can't be converted.
|
2966 + | pub fn as_string(&self) -> ::std::result::Result<&crate::model::RecursiveEnumString, &Self> {
|
2967 + | if let RecursiveUnionOne::String(val) = &self {
|
2968 + | ::std::result::Result::Ok(val)
|
2969 + | } else {
|
2970 + | ::std::result::Result::Err(self)
|
2971 + | }
|
2972 + | }
|
2973 + | /// Returns true if this is a [`String`](crate::model::RecursiveUnionOne::String).
|
2974 + | pub fn is_string(&self) -> bool {
|
2975 + | self.as_string().is_ok()
|
2976 + | }
|
2977 + | /// Tries to convert the enum instance into [`Union`](crate::model::RecursiveUnionOne::Union), extracting the inner [`RecursiveUnionTwo`](crate::model::RecursiveUnionTwo).
|
2978 + | /// Returns `Err(&Self)` if it can't be converted.
|
2979 + | pub fn as_union(
|
2980 + | &self,
|
2981 + | ) -> ::std::result::Result<&::std::boxed::Box<crate::model::RecursiveUnionTwo>, &Self> {
|
2982 + | if let RecursiveUnionOne::Union(val) = &self {
|
2983 + | ::std::result::Result::Ok(val)
|
2984 + | } else {
|
2985 + | ::std::result::Result::Err(self)
|
2986 + | }
|
2987 + | }
|
2988 + | /// Returns true if this is a [`Union`](crate::model::RecursiveUnionOne::Union).
|
2989 + | pub fn is_union(&self) -> bool {
|
2990 + | self.as_union().is_ok()
|
3433 2991 | }
|
3434 2992 | }
|
3435 - | impl EnumTraitString {
|
3436 - | /// Returns the `&str` value of the enum member.
|
2993 + |
|
2994 + | #[allow(missing_docs)] // documentation missing in model
|
2995 + | ///
|
2996 + | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
2997 + | /// [constraint traits]. Use [`SensitivePatternString::try_from`] to construct values of this type.
|
2998 + | ///
|
2999 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
3000 + | ///
|
3001 + | #[derive(
|
3002 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3003 + | )]
|
3004 + | pub struct SensitivePatternString(pub(crate) ::std::string::String);
|
3005 + | impl SensitivePatternString {
|
3006 + | /// Extracts a string slice containing the entire underlying `String`.
|
3437 3007 | pub fn as_str(&self) -> &str {
|
3438 - | match self {
|
3439 - | EnumTraitString::Abc => "abc",
|
3440 - | EnumTraitString::Def => "def",
|
3441 - | EnumTraitString::Ghi => "ghi",
|
3008 + | &self.0
|
3442 3009 | }
|
3010 + |
|
3011 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
3012 + | pub fn inner(&self) -> &::std::string::String {
|
3013 + | &self.0
|
3443 3014 | }
|
3444 - | /// Returns all the `&str` representations of the enum members.
|
3445 - | pub const fn values() -> &'static [&'static str] {
|
3446 - | &["abc", "def", "ghi"]
|
3015 + |
|
3016 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
3017 + | pub fn into_inner(self) -> ::std::string::String {
|
3018 + | self.0
|
3447 3019 | }
|
3448 3020 | }
|
3449 - | impl ::std::convert::AsRef<str> for EnumTraitString {
|
3450 - | fn as_ref(&self) -> &str {
|
3451 - | self.as_str()
|
3021 + | impl SensitivePatternString {
|
3022 + | fn check_pattern(
|
3023 + | string: ::std::string::String,
|
3024 + | ) -> ::std::result::Result<
|
3025 + | ::std::string::String,
|
3026 + | crate::model::sensitive_pattern_string::ConstraintViolation,
|
3027 + | > {
|
3028 + | let regex = Self::compile_regex();
|
3029 + |
|
3030 + | if regex.is_match(&string) {
|
3031 + | Ok(string)
|
3032 + | } else {
|
3033 + | Err(crate::model::sensitive_pattern_string::ConstraintViolation::Pattern(string))
|
3034 + | }
|
3035 + | }
|
3036 + |
|
3037 + | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
3038 + | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
3039 + | pub fn compile_regex() -> &'static ::regex::Regex {
|
3040 + | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
3041 + | ::regex::Regex::new(r#"^[a-m]+$"#).expect(r#"The regular expression ^[a-m]+$ is not supported by the `regex` crate; feel free to file an issue under https://github.com/smithy-lang/smithy-rs/issues for support"#)
|
3042 + | });
|
3043 + |
|
3044 + | ®EX
|
3452 3045 | }
|
3453 3046 | }
|
3454 - | impl crate::constrained::Constrained for EnumTraitString {
|
3047 + | impl ::std::convert::TryFrom<::std::string::String> for SensitivePatternString {
|
3048 + | type Error = crate::model::sensitive_pattern_string::ConstraintViolation;
|
3049 + |
|
3050 + | /// Constructs a `SensitivePatternString` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
3051 + | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
3052 + | let value = Self::check_pattern(value)?;
|
3053 + |
|
3054 + | Ok(Self(value))
|
3055 + | }
|
3056 + | }
|
3057 + | impl crate::constrained::Constrained for SensitivePatternString {
|
3455 3058 | type Unconstrained = ::std::string::String;
|
3456 3059 | }
|
3457 3060 |
|
3458 3061 | impl ::std::convert::From<::std::string::String>
|
3459 - | for crate::constrained::MaybeConstrained<crate::model::EnumTraitString>
|
3062 + | for crate::constrained::MaybeConstrained<crate::model::SensitivePatternString>
|
3460 3063 | {
|
3461 3064 | fn from(value: ::std::string::String) -> Self {
|
3462 3065 | Self::Unconstrained(value)
|
3463 3066 | }
|
3464 3067 | }
|
3465 - | /// See [`ValidationExceptionField`](crate::model::ValidationExceptionField).
|
3466 - | pub mod validation_exception_field {
|
3467 3068 |
|
3468 - | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
3469 - | /// Holds one variant for each of the ways the builder can fail.
|
3470 - | #[non_exhaustive]
|
3471 - | #[allow(clippy::enum_variant_names)]
|
3472 - | pub enum ConstraintViolation {
|
3473 - | /// `path` was not provided but it is required when building `ValidationExceptionField`.
|
3474 - | MissingPath,
|
3475 - | /// `message` was not provided but it is required when building `ValidationExceptionField`.
|
3476 - | MissingMessage,
|
3477 - | }
|
3478 - | impl ::std::fmt::Display for ConstraintViolation {
|
3069 + | impl ::std::fmt::Display for SensitivePatternString {
|
3479 3070 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3480 - | match self {
|
3481 - | ConstraintViolation::MissingPath => write!(f, "`path` was not provided but it is required when building `ValidationExceptionField`"),
|
3482 - | ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `ValidationExceptionField`"),
|
3483 - | }
|
3484 - | }
|
3071 + | "*** Sensitive Data Redacted ***".fmt(f)
|
3485 3072 | }
|
3486 - | impl ::std::error::Error for ConstraintViolation {}
|
3487 - | impl ::std::convert::TryFrom<Builder> for crate::model::ValidationExceptionField {
|
3488 - | type Error = ConstraintViolation;
|
3073 + | }
|
3489 3074 |
|
3490 - | fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
|
3491 - | builder.build()
|
3492 - | }
|
3075 + | impl ::std::convert::From<SensitivePatternString> for ::std::string::String {
|
3076 + | fn from(value: SensitivePatternString) -> Self {
|
3077 + | value.into_inner()
|
3493 3078 | }
|
3494 - | /// A builder for [`ValidationExceptionField`](crate::model::ValidationExceptionField).
|
3495 - | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
3496 - | pub struct Builder {
|
3497 - | pub(crate) path: ::std::option::Option<::std::string::String>,
|
3498 - | pub(crate) message: ::std::option::Option<::std::string::String>,
|
3079 + | }
|
3080 + |
|
3081 + | #[cfg(test)]
|
3082 + | mod test_sensitive_pattern_string {
|
3083 + | #[test]
|
3084 + | fn regex_compiles() {
|
3085 + | crate::model::SensitivePatternString::compile_regex();
|
3499 3086 | }
|
3500 - | impl Builder {
|
3087 + | }
|
3088 + |
|
3089 + | /// Describes one specific validation failure for an input member.
|
3090 + | #[derive(
|
3091 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3092 + | )]
|
3093 + | pub struct ValidationExceptionField {
|
3501 3094 | /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
|
3502 - | pub fn path(mut self, input: ::std::string::String) -> Self {
|
3503 - | self.path = Some(input);
|
3504 - | self
|
3505 - | }
|
3095 + | pub path: ::std::string::String,
|
3506 3096 | /// A detailed description of the validation failure.
|
3507 - | pub fn message(mut self, input: ::std::string::String) -> Self {
|
3508 - | self.message = Some(input);
|
3509 - | self
|
3510 - | }
|
3511 - | /// Consumes the builder and constructs a [`ValidationExceptionField`](crate::model::ValidationExceptionField).
|
3512 - | ///
|
3513 - | /// The builder fails to construct a [`ValidationExceptionField`](crate::model::ValidationExceptionField) if a [`ConstraintViolation`] occurs.
|
3514 - | ///
|
3515 - | /// If the builder fails, it will return the _first_ encountered [`ConstraintViolation`].
|
3516 - | pub fn build(self) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
|
3517 - | self.build_enforcing_all_constraints()
|
3518 - | }
|
3519 - | fn build_enforcing_all_constraints(
|
3520 - | self,
|
3521 - | ) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
|
3522 - | Ok(crate::model::ValidationExceptionField {
|
3523 - | path: self.path.ok_or(ConstraintViolation::MissingPath)?,
|
3524 - | message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
|
3525 - | })
|
3097 + | pub message: ::std::string::String,
|
3098 + | }
|
3099 + | impl ValidationExceptionField {
|
3100 + | /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
|
3101 + | pub fn path(&self) -> &str {
|
3102 + | use std::ops::Deref;
|
3103 + | self.path.deref()
|
3526 3104 | }
|
3105 + | /// A detailed description of the validation failure.
|
3106 + | pub fn message(&self) -> &str {
|
3107 + | use std::ops::Deref;
|
3108 + | self.message.deref()
|
3527 3109 | }
|
3528 3110 | }
|
3529 - | /// See [`SensitivePatternString`](crate::model::SensitivePatternString).
|
3530 - | pub mod sensitive_pattern_string {
|
3531 - |
|
3532 - | #[derive(Debug, PartialEq)]
|
3533 - | pub enum ConstraintViolation {
|
3534 - | /// Error when a string doesn't satisfy its `@pattern`.
|
3535 - | /// Contains the String that failed the pattern.
|
3536 - | Pattern(String),
|
3111 + | impl ValidationExceptionField {
|
3112 + | /// Creates a new builder-style object to manufacture [`ValidationExceptionField`](crate::model::ValidationExceptionField).
|
3113 + | pub fn builder() -> crate::model::validation_exception_field::Builder {
|
3114 + | crate::model::validation_exception_field::Builder::default()
|
3537 3115 | }
|
3116 + | }
|
3538 3117 |
|
3539 - | impl ::std::fmt::Display for ConstraintViolation {
|
3540 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3541 - | let message = match self {
|
3542 - | Self::Pattern(_) => {
|
3543 - | format!(
|
3544 - | r#"Value provided for `aws.protocoltests.restjson.validation#SensitivePatternString` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
3545 - | r#"^[a-m]+$"#
|
3546 - | )
|
3547 - | }
|
3548 - | };
|
3549 - | write!(f, "{message}")
|
3550 - | }
|
3551 - | }
|
3552 - |
|
3553 - | impl ::std::error::Error for ConstraintViolation {}
|
3554 - | impl ConstraintViolation {
|
3555 - | pub(crate) fn as_validation_exception_field(
|
3556 - | self,
|
3557 - | path: ::std::string::String,
|
3558 - | ) -> crate::model::ValidationExceptionField {
|
3559 - | match self {
|
3560 - | #[allow(unused_variables)]
|
3561 - | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
3562 - | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^[a-m]+$"#),
|
3563 - | path
|
3564 - | },
|
3565 - | }
|
3566 - | }
|
3567 - | }
|
3118 + | #[allow(missing_docs)] // documentation missing in model
|
3119 + | #[derive(
|
3120 + | ::std::clone::Clone,
|
3121 + | ::std::cmp::Eq,
|
3122 + | ::std::cmp::Ord,
|
3123 + | ::std::cmp::PartialEq,
|
3124 + | ::std::cmp::PartialOrd,
|
3125 + | ::std::fmt::Debug,
|
3126 + | ::std::hash::Hash,
|
3127 + | )]
|
3128 + | pub enum FooEnum {
|
3129 + | #[allow(missing_docs)] // documentation missing in model
|
3130 + | Zero,
|
3131 + | #[allow(missing_docs)] // documentation missing in model
|
3132 + | One,
|
3133 + | #[allow(missing_docs)] // documentation missing in model
|
3134 + | Bar,
|
3135 + | #[allow(missing_docs)] // documentation missing in model
|
3136 + | Baz,
|
3137 + | #[allow(missing_docs)] // documentation missing in model
|
3138 + | Foo,
|
3568 3139 | }
|
3569 - | pub mod recursive_union_one {
|
3140 + | /// See [`FooEnum`](crate::model::FooEnum).
|
3141 + | pub mod foo_enum {
|
3142 + | #[derive(Debug, PartialEq)]
|
3143 + | pub struct ConstraintViolation(pub(crate) ::std::string::String);
|
3570 3144 |
|
3571 - | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
3572 - | #[allow(clippy::enum_variant_names)]
|
3573 - | pub enum ConstraintViolation {
|
3574 - | String(crate::model::recursive_enum_string::ConstraintViolation),
|
3575 - | Union(::std::boxed::Box<crate::model::recursive_union_two::ConstraintViolation>),
|
3576 - | }
|
3577 3145 | impl ::std::fmt::Display for ConstraintViolation {
|
3578 3146 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3579 - | match self {
|
3580 - | Self::String(inner) => write!(f, "{inner}"),
|
3581 - | Self::Union(inner) => write!(f, "{inner}"),
|
3582 - | }
|
3147 + | write!(
|
3148 + | f,
|
3149 + | r#"Value provided for 'aws.protocoltests.shared#FooEnum' failed to satisfy constraint: Member must satisfy enum value set: [Foo, Baz, Bar, 1, 0]"#
|
3150 + | )
|
3583 3151 | }
|
3584 3152 | }
|
3585 3153 |
|
3586 3154 | impl ::std::error::Error for ConstraintViolation {}
|
3587 3155 | impl ConstraintViolation {
|
3588 3156 | pub(crate) fn as_validation_exception_field(
|
3589 3157 | self,
|
3590 3158 | path: ::std::string::String,
|
3591 3159 | ) -> crate::model::ValidationExceptionField {
|
3592 - | match self {
|
3593 - | Self::String(inner) => inner.as_validation_exception_field(path + "/string"),
|
3594 - | Self::Union(inner) => inner.as_validation_exception_field(path + "/union"),
|
3160 + | crate::model::ValidationExceptionField {
|
3161 + | message: format!(
|
3162 + | r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [Foo, Baz, Bar, 1, 0]"#,
|
3163 + | &path
|
3164 + | ),
|
3165 + | path,
|
3595 3166 | }
|
3596 3167 | }
|
3597 3168 | }
|
3598 3169 | }
|
3599 - | pub mod recursive_union_two {
|
3600 - |
|
3601 - | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
3602 - | #[allow(clippy::enum_variant_names)]
|
3603 - | pub enum ConstraintViolation {
|
3604 - | String(crate::model::recursive_enum_string::ConstraintViolation),
|
3605 - | Union(crate::model::recursive_union_one::ConstraintViolation),
|
3170 + | impl ::std::convert::TryFrom<&str> for FooEnum {
|
3171 + | type Error = crate::model::foo_enum::ConstraintViolation;
|
3172 + | fn try_from(
|
3173 + | s: &str,
|
3174 + | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<&str>>::Error> {
|
3175 + | match s {
|
3176 + | "0" => Ok(FooEnum::Zero),
|
3177 + | "1" => Ok(FooEnum::One),
|
3178 + | "Bar" => Ok(FooEnum::Bar),
|
3179 + | "Baz" => Ok(FooEnum::Baz),
|
3180 + | "Foo" => Ok(FooEnum::Foo),
|
3181 + | _ => Err(crate::model::foo_enum::ConstraintViolation(s.to_owned())),
|
3606 3182 | }
|
3607 - | impl ::std::fmt::Display for ConstraintViolation {
|
3608 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3609 - | match self {
|
3610 - | Self::String(inner) => write!(f, "{inner}"),
|
3611 - | Self::Union(inner) => write!(f, "{inner}"),
|
3612 3183 | }
|
3184 + | }
|
3185 + | impl ::std::convert::TryFrom<::std::string::String> for FooEnum {
|
3186 + | type Error = crate::model::foo_enum::ConstraintViolation;
|
3187 + | fn try_from(
|
3188 + | s: ::std::string::String,
|
3189 + | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<::std::string::String>>::Error>
|
3190 + | {
|
3191 + | s.as_str().try_into()
|
3613 3192 | }
|
3193 + | }
|
3194 + | impl std::str::FromStr for FooEnum {
|
3195 + | type Err = crate::model::foo_enum::ConstraintViolation;
|
3196 + | fn from_str(s: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
|
3197 + | Self::try_from(s)
|
3614 3198 | }
|
3615 - |
|
3616 - | impl ::std::error::Error for ConstraintViolation {}
|
3617 - | impl ConstraintViolation {
|
3618 - | pub(crate) fn as_validation_exception_field(
|
3619 - | self,
|
3620 - | path: ::std::string::String,
|
3621 - | ) -> crate::model::ValidationExceptionField {
|
3199 + | }
|
3200 + | impl FooEnum {
|
3201 + | /// Returns the `&str` value of the enum member.
|
3202 + | pub fn as_str(&self) -> &str {
|
3622 3203 | match self {
|
3623 - | Self::String(inner) => inner.as_validation_exception_field(path + "/string"),
|
3624 - | Self::Union(inner) => inner.as_validation_exception_field(path + "/union"),
|
3204 + | FooEnum::Zero => "0",
|
3205 + | FooEnum::One => "1",
|
3206 + | FooEnum::Bar => "Bar",
|
3207 + | FooEnum::Baz => "Baz",
|
3208 + | FooEnum::Foo => "Foo",
|
3625 3209 | }
|
3626 3210 | }
|
3211 + | /// Returns all the `&str` representations of the enum members.
|
3212 + | pub const fn values() -> &'static [&'static str] {
|
3213 + | &["0", "1", "Bar", "Baz", "Foo"]
|
3627 3214 | }
|
3628 3215 | }
|
3629 - | /// See [`UnionSet`](crate::model::UnionSet).
|
3630 - | pub mod union_set {
|
3216 + | impl ::std::convert::AsRef<str> for FooEnum {
|
3217 + | fn as_ref(&self) -> &str {
|
3218 + | self.as_str()
|
3219 + | }
|
3220 + | }
|
3221 + | impl crate::constrained::Constrained for FooEnum {
|
3222 + | type Unconstrained = ::std::string::String;
|
3223 + | }
|
3631 3224 |
|
3632 - | #[allow(clippy::enum_variant_names)]
|
3633 - | #[derive(Debug, PartialEq)]
|
3634 - | pub enum ConstraintViolation {
|
3635 - | /// Constraint violation error when the list does not contain unique items
|
3636 - | UniqueItems {
|
3637 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
3638 - | /// at least two elements.
|
3639 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
3640 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
3641 - | /// Nothing is guaranteed about the order of the indices.
|
3642 - | duplicate_indices: ::std::vec::Vec<usize>,
|
3643 - | /// The original vector, that contains duplicate items.
|
3644 - | original: ::std::vec::Vec<crate::model::FooUnion>,
|
3645 - | },
|
3225 + | impl ::std::convert::From<::std::string::String>
|
3226 + | for crate::constrained::MaybeConstrained<crate::model::FooEnum>
|
3227 + | {
|
3228 + | fn from(value: ::std::string::String) -> Self {
|
3229 + | Self::Unconstrained(value)
|
3646 3230 | }
|
3231 + | }
|
3647 3232 |
|
3648 - | impl ::std::fmt::Display for ConstraintViolation {
|
3649 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3650 - | let message = match self {
|
3651 - | Self::UniqueItems { duplicate_indices, .. } =>
|
3652 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#UnionSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
3653 - | };
|
3654 - | write!(f, "{message}")
|
3233 + | #[allow(missing_docs)] // documentation missing in model
|
3234 + | #[derive(
|
3235 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3236 + | )]
|
3237 + | pub struct GreetingStruct {
|
3238 + | #[allow(missing_docs)] // documentation missing in model
|
3239 + | pub hi: ::std::option::Option<::std::string::String>,
|
3240 + | }
|
3241 + | impl GreetingStruct {
|
3242 + | #[allow(missing_docs)] // documentation missing in model
|
3243 + | pub fn hi(&self) -> ::std::option::Option<&str> {
|
3244 + | self.hi.as_deref()
|
3655 3245 | }
|
3246 + | }
|
3247 + | impl GreetingStruct {
|
3248 + | /// Creates a new builder-style object to manufacture [`GreetingStruct`](crate::model::GreetingStruct).
|
3249 + | pub fn builder() -> crate::model::greeting_struct::Builder {
|
3250 + | crate::model::greeting_struct::Builder::default()
|
3656 3251 | }
|
3252 + | }
|
3253 + | impl crate::constrained::Constrained for crate::model::GreetingStruct {
|
3254 + | type Unconstrained = crate::model::greeting_struct::Builder;
|
3255 + | }
|
3657 3256 |
|
3658 - | impl ::std::error::Error for ConstraintViolation {}
|
3659 - | impl ConstraintViolation {
|
3660 - | pub(crate) fn as_validation_exception_field(
|
3661 - | self,
|
3662 - | path: ::std::string::String,
|
3663 - | ) -> crate::model::ValidationExceptionField {
|
3664 - | match self {
|
3665 - | Self::UniqueItems { duplicate_indices, .. } =>
|
3666 - | crate::model::ValidationExceptionField {
|
3667 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
3668 - | path,
|
3669 - | },
|
3670 - | }
|
3257 + | #[allow(missing_docs)] // documentation missing in model
|
3258 + | #[derive(
|
3259 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3260 + | )]
|
3261 + | pub struct MissingKeyStructure {
|
3262 + | #[allow(missing_docs)] // documentation missing in model
|
3263 + | pub hi: ::std::string::String,
|
3264 + | }
|
3265 + | impl MissingKeyStructure {
|
3266 + | #[allow(missing_docs)] // documentation missing in model
|
3267 + | pub fn hi(&self) -> &str {
|
3268 + | use std::ops::Deref;
|
3269 + | self.hi.deref()
|
3671 3270 | }
|
3271 + | }
|
3272 + | impl MissingKeyStructure {
|
3273 + | /// Creates a new builder-style object to manufacture [`MissingKeyStructure`](crate::model::MissingKeyStructure).
|
3274 + | pub fn builder() -> crate::model::missing_key_structure::Builder {
|
3275 + | crate::model::missing_key_structure::Builder::default()
|
3672 3276 | }
|
3673 3277 | }
|
3674 - | /// See [`StructureSetWithNoKey`](crate::model::StructureSetWithNoKey).
|
3675 - | pub mod structure_set_with_no_key {
|
3278 + | impl crate::constrained::Constrained for crate::model::MissingKeyStructure {
|
3279 + | type Unconstrained = crate::model::missing_key_structure::Builder;
|
3280 + | }
|
3676 3281 |
|
3677 - | #[allow(clippy::enum_variant_names)]
|
3678 - | #[derive(Debug, PartialEq)]
|
3679 - | pub enum ConstraintViolation {
|
3680 - | /// Constraint violation error when the list does not contain unique items
|
3681 - | UniqueItems {
|
3682 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
3683 - | /// at least two elements.
|
3684 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
3685 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
3686 - | /// Nothing is guaranteed about the order of the indices.
|
3687 - | duplicate_indices: ::std::vec::Vec<usize>,
|
3688 - | /// The original vector, that contains duplicate items.
|
3689 - | original: ::std::vec::Vec<crate::model::MissingKeyStructure>,
|
3690 - | },
|
3691 - | /// Constraint violation error when an element doesn't satisfy its own constraints.
|
3692 - | /// The first component of the tuple is the index in the collection where the
|
3693 - | /// first constraint violation was found.
|
3694 - | #[doc(hidden)]
|
3695 - | Member(
|
3696 - | usize,
|
3697 - | crate::model::missing_key_structure::ConstraintViolation,
|
3698 - | ),
|
3282 + | #[allow(missing_docs)] // documentation missing in model
|
3283 + | #[derive(
|
3284 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3285 + | )]
|
3286 + | pub enum FooUnion {
|
3287 + | #[allow(missing_docs)] // documentation missing in model
|
3288 + | Integer(i32),
|
3289 + | #[allow(missing_docs)] // documentation missing in model
|
3290 + | String(::std::string::String),
|
3291 + | }
|
3292 + | impl FooUnion {
|
3293 + | /// Tries to convert the enum instance into [`Integer`](crate::model::FooUnion::Integer), extracting the inner [`i32`](i32).
|
3294 + | /// Returns `Err(&Self)` if it can't be converted.
|
3295 + | pub fn as_integer(&self) -> ::std::result::Result<&i32, &Self> {
|
3296 + | if let FooUnion::Integer(val) = &self {
|
3297 + | ::std::result::Result::Ok(val)
|
3298 + | } else {
|
3299 + | ::std::result::Result::Err(self)
|
3699 3300 | }
|
3700 - |
|
3701 - | impl ::std::fmt::Display for ConstraintViolation {
|
3702 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3703 - | let message = match self {
|
3704 - | Self::UniqueItems { duplicate_indices, .. } =>
|
3705 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.restjson.validation#StructureSetWithNoKey' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
3706 - | Self::Member(index, failing_member) => format!("Value at index {index} failed to satisfy constraint. {}",
|
3707 - | failing_member)
|
3708 - | };
|
3709 - | write!(f, "{message}")
|
3710 3301 | }
|
3302 + | /// Returns true if this is a [`Integer`](crate::model::FooUnion::Integer).
|
3303 + | pub fn is_integer(&self) -> bool {
|
3304 + | self.as_integer().is_ok()
|
3711 3305 | }
|
3712 - |
|
3713 - | impl ::std::error::Error for ConstraintViolation {}
|
3714 - | impl ConstraintViolation {
|
3715 - | pub(crate) fn as_validation_exception_field(
|
3716 - | self,
|
3717 - | path: ::std::string::String,
|
3718 - | ) -> crate::model::ValidationExceptionField {
|
3719 - | match self {
|
3720 - | Self::UniqueItems { duplicate_indices, .. } =>
|
3721 - | crate::model::ValidationExceptionField {
|
3722 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
3723 - | path,
|
3724 - | },
|
3725 - | Self::Member(index, member_constraint_violation) =>
|
3726 - | member_constraint_violation.as_validation_exception_field(path + "/" + &index.to_string())
|
3306 + | /// Tries to convert the enum instance into [`String`](crate::model::FooUnion::String), extracting the inner [`String`](::std::string::String).
|
3307 + | /// Returns `Err(&Self)` if it can't be converted.
|
3308 + | pub fn as_string(&self) -> ::std::result::Result<&::std::string::String, &Self> {
|
3309 + | if let FooUnion::String(val) = &self {
|
3310 + | ::std::result::Result::Ok(val)
|
3311 + | } else {
|
3312 + | ::std::result::Result::Err(self)
|
3727 3313 | }
|
3728 3314 | }
|
3315 + | /// Returns true if this is a [`String`](crate::model::FooUnion::String).
|
3316 + | pub fn is_string(&self) -> bool {
|
3317 + | self.as_string().is_ok()
|
3729 3318 | }
|
3730 3319 | }
|
3731 - | /// See [`MissingKeyStructure`](crate::model::MissingKeyStructure).
|
3732 - | pub mod missing_key_structure {
|
3733 3320 |
|
3734 - | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
3735 - | /// Holds one variant for each of the ways the builder can fail.
|
3736 - | #[non_exhaustive]
|
3737 - | #[allow(clippy::enum_variant_names)]
|
3738 - | pub enum ConstraintViolation {
|
3739 - | /// `hi` was not provided but it is required when building `MissingKeyStructure`.
|
3740 - | MissingHi,
|
3741 - | }
|
3321 + | #[allow(missing_docs)] // documentation missing in model
|
3322 + | #[derive(
|
3323 + | ::std::clone::Clone,
|
3324 + | ::std::cmp::Eq,
|
3325 + | ::std::cmp::Ord,
|
3326 + | ::std::cmp::PartialEq,
|
3327 + | ::std::cmp::PartialOrd,
|
3328 + | ::std::fmt::Debug,
|
3329 + | ::std::hash::Hash,
|
3330 + | )]
|
3331 + | pub enum RecursiveEnumString {
|
3332 + | #[allow(missing_docs)] // documentation missing in model
|
3333 + | Abc,
|
3334 + | #[allow(missing_docs)] // documentation missing in model
|
3335 + | Def,
|
3336 + | }
|
3337 + | /// See [`RecursiveEnumString`](crate::model::RecursiveEnumString).
|
3338 + | pub mod recursive_enum_string {
|
3339 + | #[derive(Debug, PartialEq)]
|
3340 + | pub struct ConstraintViolation(pub(crate) ::std::string::String);
|
3341 + |
|
3742 3342 | impl ::std::fmt::Display for ConstraintViolation {
|
3743 3343 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3744 - | match self {
|
3745 - | ConstraintViolation::MissingHi => write!(
|
3344 + | write!(
|
3746 3345 | f,
|
3747 - | "`hi` was not provided but it is required when building `MissingKeyStructure`"
|
3748 - | ),
|
3749 - | }
|
3346 + | r#"Value provided for 'aws.protocoltests.restjson.validation#RecursiveEnumString' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]"#
|
3347 + | )
|
3750 3348 | }
|
3751 3349 | }
|
3350 + |
|
3752 3351 | impl ::std::error::Error for ConstraintViolation {}
|
3753 3352 | impl ConstraintViolation {
|
3754 3353 | pub(crate) fn as_validation_exception_field(
|
3755 3354 | self,
|
3756 3355 | path: ::std::string::String,
|
3757 3356 | ) -> crate::model::ValidationExceptionField {
|
3758 - | match self {
|
3759 - | ConstraintViolation::MissingHi => crate::model::ValidationExceptionField {
|
3357 + | crate::model::ValidationExceptionField {
|
3760 3358 | message: format!(
|
3761 - | "Value at '{}/hi' failed to satisfy constraint: Member must not be null",
|
3762 - | path
|
3359 + | r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]"#,
|
3360 + | &path
|
3763 3361 | ),
|
3764 - | path: path + "/hi",
|
3765 - | },
|
3362 + | path,
|
3766 3363 | }
|
3767 3364 | }
|
3768 3365 | }
|
3769 - | impl ::std::convert::From<Builder>
|
3770 - | for crate::constrained::MaybeConstrained<crate::model::MissingKeyStructure>
|
3366 + | }
|
3367 + | impl ::std::convert::TryFrom<&str> for RecursiveEnumString {
|
3368 + | type Error = crate::model::recursive_enum_string::ConstraintViolation;
|
3369 + | fn try_from(
|
3370 + | s: &str,
|
3371 + | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<&str>>::Error> {
|
3372 + | match s {
|
3373 + | "abc" => Ok(RecursiveEnumString::Abc),
|
3374 + | "def" => Ok(RecursiveEnumString::Def),
|
3375 + | _ => Err(crate::model::recursive_enum_string::ConstraintViolation(
|
3376 + | s.to_owned(),
|
3377 + | )),
|
3378 + | }
|
3379 + | }
|
3380 + | }
|
3381 + | impl ::std::convert::TryFrom<::std::string::String> for RecursiveEnumString {
|
3382 + | type Error = crate::model::recursive_enum_string::ConstraintViolation;
|
3383 + | fn try_from(
|
3384 + | s: ::std::string::String,
|
3385 + | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<::std::string::String>>::Error>
|
3771 3386 | {
|
3772 - | fn from(builder: Builder) -> Self {
|
3773 - | Self::Unconstrained(builder)
|
3387 + | s.as_str().try_into()
|
3774 3388 | }
|
3389 + | }
|
3390 + | impl std::str::FromStr for RecursiveEnumString {
|
3391 + | type Err = crate::model::recursive_enum_string::ConstraintViolation;
|
3392 + | fn from_str(s: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
|
3393 + | Self::try_from(s)
|
3775 3394 | }
|
3776 - | impl ::std::convert::TryFrom<Builder> for crate::model::MissingKeyStructure {
|
3777 - | type Error = ConstraintViolation;
|
3778 - |
|
3779 - | fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
|
3780 - | builder.build()
|
3395 + | }
|
3396 + | impl RecursiveEnumString {
|
3397 + | /// Returns the `&str` value of the enum member.
|
3398 + | pub fn as_str(&self) -> &str {
|
3399 + | match self {
|
3400 + | RecursiveEnumString::Abc => "abc",
|
3401 + | RecursiveEnumString::Def => "def",
|
3781 3402 | }
|
3782 3403 | }
|
3783 - | /// A builder for [`MissingKeyStructure`](crate::model::MissingKeyStructure).
|
3784 - | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
3785 - | pub struct Builder {
|
3786 - | pub(crate) hi: ::std::option::Option<::std::string::String>,
|
3404 + | /// Returns all the `&str` representations of the enum members.
|
3405 + | pub const fn values() -> &'static [&'static str] {
|
3406 + | &["abc", "def"]
|
3787 3407 | }
|
3788 - | impl Builder {
|
3789 - | #[allow(missing_docs)] // documentation missing in model
|
3790 - | pub fn hi(mut self, input: ::std::string::String) -> Self {
|
3791 - | self.hi = Some(input);
|
3792 - | self
|
3408 + | }
|
3409 + | impl ::std::convert::AsRef<str> for RecursiveEnumString {
|
3410 + | fn as_ref(&self) -> &str {
|
3411 + | self.as_str()
|
3412 + | }
|
3413 + | }
|
3414 + | impl crate::constrained::Constrained for RecursiveEnumString {
|
3415 + | type Unconstrained = ::std::string::String;
|
3416 + | }
|
3417 + |
|
3418 + | impl ::std::convert::From<::std::string::String>
|
3419 + | for crate::constrained::MaybeConstrained<crate::model::RecursiveEnumString>
|
3420 + | {
|
3421 + | fn from(value: ::std::string::String) -> Self {
|
3422 + | Self::Unconstrained(value)
|
3793 3423 | }
|
3424 + | }
|
3425 + |
|
3426 + | #[allow(missing_docs)] // documentation missing in model
|
3427 + | #[derive(
|
3428 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3429 + | )]
|
3430 + | pub enum RecursiveUnionTwo {
|
3794 3431 | #[allow(missing_docs)] // documentation missing in model
|
3795 - | pub(crate) fn set_hi(
|
3796 - | mut self,
|
3797 - | input: impl ::std::convert::Into<::std::string::String>,
|
3798 - | ) -> Self {
|
3799 - | self.hi = Some(input.into());
|
3800 - | self
|
3432 + | String(crate::model::RecursiveEnumString),
|
3433 + | #[allow(missing_docs)] // documentation missing in model
|
3434 + | Union(crate::model::RecursiveUnionOne),
|
3435 + | }
|
3436 + | impl RecursiveUnionTwo {
|
3437 + | /// Tries to convert the enum instance into [`String`](crate::model::RecursiveUnionTwo::String), extracting the inner [`RecursiveEnumString`](crate::model::RecursiveEnumString).
|
3438 + | /// Returns `Err(&Self)` if it can't be converted.
|
3439 + | pub fn as_string(&self) -> ::std::result::Result<&crate::model::RecursiveEnumString, &Self> {
|
3440 + | if let RecursiveUnionTwo::String(val) = &self {
|
3441 + | ::std::result::Result::Ok(val)
|
3442 + | } else {
|
3443 + | ::std::result::Result::Err(self)
|
3801 3444 | }
|
3802 - | /// Consumes the builder and constructs a [`MissingKeyStructure`](crate::model::MissingKeyStructure).
|
3803 - | ///
|
3804 - | /// The builder fails to construct a [`MissingKeyStructure`](crate::model::MissingKeyStructure) if a [`ConstraintViolation`] occurs.
|
3805 - | ///
|
3806 - | pub fn build(self) -> Result<crate::model::MissingKeyStructure, ConstraintViolation> {
|
3807 - | self.build_enforcing_all_constraints()
|
3808 3445 | }
|
3809 - | fn build_enforcing_all_constraints(
|
3810 - | self,
|
3811 - | ) -> Result<crate::model::MissingKeyStructure, ConstraintViolation> {
|
3812 - | Ok(crate::model::MissingKeyStructure {
|
3813 - | hi: self.hi.ok_or(ConstraintViolation::MissingHi)?,
|
3814 - | })
|
3446 + | /// Returns true if this is a [`String`](crate::model::RecursiveUnionTwo::String).
|
3447 + | pub fn is_string(&self) -> bool {
|
3448 + | self.as_string().is_ok()
|
3449 + | }
|
3450 + | /// Tries to convert the enum instance into [`Union`](crate::model::RecursiveUnionTwo::Union), extracting the inner [`RecursiveUnionOne`](crate::model::RecursiveUnionOne).
|
3451 + | /// Returns `Err(&Self)` if it can't be converted.
|
3452 + | pub fn as_union(&self) -> ::std::result::Result<&crate::model::RecursiveUnionOne, &Self> {
|
3453 + | if let RecursiveUnionTwo::Union(val) = &self {
|
3454 + | ::std::result::Result::Ok(val)
|
3455 + | } else {
|
3456 + | ::std::result::Result::Err(self)
|
3815 3457 | }
|
3816 3458 | }
|
3459 + | /// Returns true if this is a [`Union`](crate::model::RecursiveUnionTwo::Union).
|
3460 + | pub fn is_union(&self) -> bool {
|
3461 + | self.as_union().is_ok()
|
3462 + | }
|
3817 3463 | }
|
3818 - | /// See [`StructureSet`](crate::model::StructureSet).
|
3819 - | pub mod structure_set {
|
3464 + |
|
3465 + | pub mod enum_list {
|
3820 3466 |
|
3821 3467 | #[allow(clippy::enum_variant_names)]
|
3822 3468 | #[derive(Debug, PartialEq)]
|
3823 3469 | pub enum ConstraintViolation {
|
3824 - | /// Constraint violation error when the list does not contain unique items
|
3825 - | UniqueItems {
|
3826 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
3827 - | /// at least two elements.
|
3828 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
3829 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
3830 - | /// Nothing is guaranteed about the order of the indices.
|
3831 - | duplicate_indices: ::std::vec::Vec<usize>,
|
3832 - | /// The original vector, that contains duplicate items.
|
3833 - | original: ::std::vec::Vec<crate::model::GreetingStruct>,
|
3834 - | },
|
3470 + | /// Constraint violation error when an element doesn't satisfy its own constraints.
|
3471 + | /// The first component of the tuple is the index in the collection where the
|
3472 + | /// first constraint violation was found.
|
3473 + | #[doc(hidden)]
|
3474 + | Member(usize, crate::model::enum_string::ConstraintViolation),
|
3835 3475 | }
|
3836 3476 |
|
3837 3477 | impl ::std::fmt::Display for ConstraintViolation {
|
3838 3478 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3839 3479 | let message = match self {
|
3840 - | Self::UniqueItems { duplicate_indices, .. } =>
|
3841 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#StructureSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
3480 + | Self::Member(index, failing_member) => format!(
|
3481 + | "Value at index {index} failed to satisfy constraint. {}",
|
3482 + | failing_member
|
3483 + | ),
|
3842 3484 | };
|
3843 3485 | write!(f, "{message}")
|
3844 3486 | }
|
3845 3487 | }
|
3846 3488 |
|
3847 3489 | impl ::std::error::Error for ConstraintViolation {}
|
3848 3490 | impl ConstraintViolation {
|
3849 3491 | pub(crate) fn as_validation_exception_field(
|
3850 3492 | self,
|
3851 3493 | path: ::std::string::String,
|
3852 3494 | ) -> crate::model::ValidationExceptionField {
|
3853 3495 | match self {
|
3854 - | Self::UniqueItems { duplicate_indices, .. } =>
|
3855 - | crate::model::ValidationExceptionField {
|
3856 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
3857 - | path,
|
3858 - | },
|
3859 - | }
|
3860 - | }
|
3861 - | }
|
3862 - | }
|
3863 - | /// See [`GreetingStruct`](crate::model::GreetingStruct).
|
3864 - | pub mod greeting_struct {
|
3865 - |
|
3866 - | impl ::std::convert::From<Builder> for crate::model::GreetingStruct {
|
3867 - | fn from(builder: Builder) -> Self {
|
3868 - | builder.build()
|
3869 - | }
|
3870 - | }
|
3871 - | /// A builder for [`GreetingStruct`](crate::model::GreetingStruct).
|
3872 - | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
3873 - | pub struct Builder {
|
3874 - | pub(crate) hi: ::std::option::Option<::std::string::String>,
|
3875 - | }
|
3876 - | impl Builder {
|
3877 - | #[allow(missing_docs)] // documentation missing in model
|
3878 - | pub fn hi(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
|
3879 - | self.hi = input;
|
3880 - | self
|
3881 - | }
|
3882 - | #[allow(missing_docs)] // documentation missing in model
|
3883 - | pub(crate) fn set_hi(
|
3884 - | mut self,
|
3885 - | input: Option<impl ::std::convert::Into<::std::string::String>>,
|
3886 - | ) -> Self {
|
3887 - | self.hi = input.map(|v| v.into());
|
3888 - | self
|
3889 - | }
|
3890 - | /// Consumes the builder and constructs a [`GreetingStruct`](crate::model::GreetingStruct).
|
3891 - | pub fn build(self) -> crate::model::GreetingStruct {
|
3892 - | self.build_enforcing_all_constraints()
|
3496 + | Self::Member(index, member_constraint_violation) => member_constraint_violation
|
3497 + | .as_validation_exception_field(path + "/" + &index.to_string()),
|
3893 3498 | }
|
3894 - | fn build_enforcing_all_constraints(self) -> crate::model::GreetingStruct {
|
3895 - | crate::model::GreetingStruct { hi: self.hi }
|
3896 3499 | }
|
3897 3500 | }
|
3898 3501 | }
|
3899 - | /// See [`ListSet`](crate::model::ListSet).
|
3900 - | pub mod list_set {
|
3502 + | pub mod enum_map {
|
3901 3503 |
|
3902 3504 | #[allow(clippy::enum_variant_names)]
|
3903 3505 | #[derive(Debug, PartialEq)]
|
3904 3506 | pub enum ConstraintViolation {
|
3905 - | /// Constraint violation error when the list does not contain unique items
|
3906 - | UniqueItems {
|
3907 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
3908 - | /// at least two elements.
|
3909 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
3910 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
3911 - | /// Nothing is guaranteed about the order of the indices.
|
3912 - | duplicate_indices: ::std::vec::Vec<usize>,
|
3913 - | /// The original vector, that contains duplicate items.
|
3914 - | original: ::std::vec::Vec<::std::vec::Vec<::std::string::String>>,
|
3915 - | },
|
3507 + | #[doc(hidden)]
|
3508 + | Key(crate::model::enum_string::ConstraintViolation),
|
3509 + | #[doc(hidden)]
|
3510 + | Value(
|
3511 + | crate::model::EnumString,
|
3512 + | crate::model::enum_string::ConstraintViolation,
|
3513 + | ),
|
3916 3514 | }
|
3917 3515 |
|
3918 3516 | impl ::std::fmt::Display for ConstraintViolation {
|
3919 3517 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3920 - | let message = match self {
|
3921 - | Self::UniqueItems { duplicate_indices, .. } =>
|
3922 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#ListSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
3923 - | };
|
3924 - | write!(f, "{message}")
|
3518 + | match self {
|
3519 + | Self::Key(key_constraint_violation) => write!(f, "{}", key_constraint_violation),
|
3520 + | Self::Value(_, value_constraint_violation) => {
|
3521 + | write!(f, "{}", value_constraint_violation)
|
3522 + | }
|
3523 + | }
|
3925 3524 | }
|
3926 3525 | }
|
3927 3526 |
|
3928 3527 | impl ::std::error::Error for ConstraintViolation {}
|
3929 3528 | impl ConstraintViolation {
|
3930 3529 | pub(crate) fn as_validation_exception_field(
|
3931 3530 | self,
|
3932 3531 | path: ::std::string::String,
|
3933 3532 | ) -> crate::model::ValidationExceptionField {
|
3934 3533 | match self {
|
3935 - | Self::UniqueItems { duplicate_indices, .. } =>
|
3936 - | crate::model::ValidationExceptionField {
|
3937 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
3938 - | path,
|
3939 - | },
|
3534 + | Self::Key(key_constraint_violation) => {
|
3535 + | key_constraint_violation.as_validation_exception_field(path)
|
3536 + | }
|
3537 + | Self::Value(key, value_constraint_violation) => value_constraint_violation
|
3538 + | .as_validation_exception_field(path + "/" + key.as_str()),
|
3940 3539 | }
|
3941 3540 | }
|
3942 3541 | }
|
3943 3542 | }
|
3944 - | /// See [`IntegerEnumSet`](crate::model::IntegerEnumSet).
|
3945 - | pub mod integer_enum_set {
|
3543 + | pub mod enum_union {
|
3946 3544 |
|
3545 + | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
3947 3546 | #[allow(clippy::enum_variant_names)]
|
3948 - | #[derive(Debug, PartialEq)]
|
3949 3547 | pub enum ConstraintViolation {
|
3950 - | /// Constraint violation error when the list does not contain unique items
|
3951 - | UniqueItems {
|
3952 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
3953 - | /// at least two elements.
|
3954 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
3955 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
3956 - | /// Nothing is guaranteed about the order of the indices.
|
3957 - | duplicate_indices: ::std::vec::Vec<usize>,
|
3958 - | /// The original vector, that contains duplicate items.
|
3959 - | original: ::std::vec::Vec<i32>,
|
3960 - | },
|
3548 + | First(crate::model::enum_string::ConstraintViolation),
|
3549 + | Second(crate::model::enum_string::ConstraintViolation),
|
3961 3550 | }
|
3962 - |
|
3963 3551 | impl ::std::fmt::Display for ConstraintViolation {
|
3964 3552 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3965 - | let message = match self {
|
3966 - | Self::UniqueItems { duplicate_indices, .. } =>
|
3967 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#IntegerEnumSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
3968 - | };
|
3969 - | write!(f, "{message}")
|
3553 + | match self {
|
3554 + | Self::First(inner) => write!(f, "{inner}"),
|
3555 + | Self::Second(inner) => write!(f, "{inner}"),
|
3556 + | }
|
3970 3557 | }
|
3971 3558 | }
|
3972 3559 |
|
3973 3560 | impl ::std::error::Error for ConstraintViolation {}
|
3974 3561 | impl ConstraintViolation {
|
3975 3562 | pub(crate) fn as_validation_exception_field(
|
3976 3563 | self,
|
3977 3564 | path: ::std::string::String,
|
3978 3565 | ) -> crate::model::ValidationExceptionField {
|
3979 3566 | match self {
|
3980 - | Self::UniqueItems { duplicate_indices, .. } =>
|
3981 - | crate::model::ValidationExceptionField {
|
3982 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
3983 - | path,
|
3984 - | },
|
3567 + | Self::First(inner) => inner.as_validation_exception_field(path + "/first"),
|
3568 + | Self::Second(inner) => inner.as_validation_exception_field(path + "/second"),
|
3985 3569 | }
|
3986 3570 | }
|
3987 3571 | }
|
3988 3572 | }
|
3989 - | /// See [`FooEnumSet`](crate::model::FooEnumSet).
|
3990 - | pub mod foo_enum_set {
|
3573 + | /// See [`LengthBlob`](crate::model::LengthBlob).
|
3574 + | pub mod length_blob {
|
3991 3575 |
|
3992 - | #[allow(clippy::enum_variant_names)]
|
3993 3576 | #[derive(Debug, PartialEq)]
|
3994 3577 | pub enum ConstraintViolation {
|
3995 - | /// Constraint violation error when the list does not contain unique items
|
3996 - | UniqueItems {
|
3997 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
3998 - | /// at least two elements.
|
3999 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
4000 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
4001 - | /// Nothing is guaranteed about the order of the indices.
|
4002 - | duplicate_indices: ::std::vec::Vec<usize>,
|
4003 - | /// The original vector, that contains duplicate items.
|
4004 - | original: ::std::vec::Vec<crate::model::FooEnum>,
|
4005 - | },
|
4006 - | /// Constraint violation error when an element doesn't satisfy its own constraints.
|
4007 - | /// The first component of the tuple is the index in the collection where the
|
4008 - | /// first constraint violation was found.
|
4009 - | #[doc(hidden)]
|
4010 - | Member(usize, crate::model::foo_enum::ConstraintViolation),
|
3578 + | /// Error when a blob doesn't satisfy its `@length` requirements.
|
3579 + | Length(usize),
|
4011 3580 | }
|
4012 3581 |
|
4013 3582 | impl ::std::fmt::Display for ConstraintViolation {
|
4014 3583 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4015 3584 | let message = match self {
|
4016 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4017 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#FooEnumSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
4018 - | Self::Member(index, failing_member) => format!("Value at index {index} failed to satisfy constraint. {}",
|
4019 - | failing_member)
|
3585 + | Self::Length(length) => {
|
3586 + | format!("Value with length {} provided for 'aws.protocoltests.restjson.validation#LengthBlob' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length)
|
3587 + | }
|
4020 3588 | };
|
4021 3589 | write!(f, "{message}")
|
4022 3590 | }
|
4023 3591 | }
|
4024 3592 |
|
4025 3593 | impl ::std::error::Error for ConstraintViolation {}
|
4026 3594 | impl ConstraintViolation {
|
4027 3595 | pub(crate) fn as_validation_exception_field(
|
4028 3596 | self,
|
4029 3597 | path: ::std::string::String,
|
4030 3598 | ) -> crate::model::ValidationExceptionField {
|
4031 3599 | match self {
|
4032 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4033 - | crate::model::ValidationExceptionField {
|
4034 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
3600 + | Self::Length(length) => crate::model::ValidationExceptionField {
|
3601 + | message: format!("Value with length {} at '{}' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length, &path),
|
4035 3602 | path,
|
4036 3603 | },
|
4037 - | Self::Member(index, member_constraint_violation) =>
|
4038 - | member_constraint_violation.as_validation_exception_field(path + "/" + &index.to_string())
|
4039 3604 | }
|
4040 3605 | }
|
4041 3606 | }
|
4042 3607 | }
|
4043 - | /// See [`HttpDateSet`](crate::model::HttpDateSet).
|
4044 - | pub mod http_date_set {
|
3608 + | /// See [`LengthString`](crate::model::LengthString).
|
3609 + | pub mod length_string {
|
4045 3610 |
|
4046 - | #[allow(clippy::enum_variant_names)]
|
4047 3611 | #[derive(Debug, PartialEq)]
|
4048 3612 | pub enum ConstraintViolation {
|
4049 - | /// Constraint violation error when the list does not contain unique items
|
4050 - | UniqueItems {
|
4051 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
4052 - | /// at least two elements.
|
4053 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
4054 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
4055 - | /// Nothing is guaranteed about the order of the indices.
|
4056 - | duplicate_indices: ::std::vec::Vec<usize>,
|
4057 - | /// The original vector, that contains duplicate items.
|
4058 - | original: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
4059 - | },
|
3613 + | /// Error when a string doesn't satisfy its `@length` requirements.
|
3614 + | Length(usize),
|
4060 3615 | }
|
4061 3616 |
|
4062 3617 | impl ::std::fmt::Display for ConstraintViolation {
|
4063 3618 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4064 3619 | let message = match self {
|
4065 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4066 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#HttpDateSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
3620 + | Self::Length(length) => {
|
3621 + | format!("Value with length {} provided for 'aws.protocoltests.restjson.validation#LengthString' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length)
|
3622 + | }
|
4067 3623 | };
|
4068 3624 | write!(f, "{message}")
|
4069 3625 | }
|
4070 3626 | }
|
4071 3627 |
|
4072 3628 | impl ::std::error::Error for ConstraintViolation {}
|
4073 3629 | impl ConstraintViolation {
|
4074 3630 | pub(crate) fn as_validation_exception_field(
|
4075 3631 | self,
|
4076 3632 | path: ::std::string::String,
|
4077 3633 | ) -> crate::model::ValidationExceptionField {
|
4078 3634 | match self {
|
4079 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4080 - | crate::model::ValidationExceptionField {
|
4081 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
3635 + | Self::Length(length) => crate::model::ValidationExceptionField {
|
3636 + | message: format!("Value with length {} at '{}' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length, &path),
|
4082 3637 | path,
|
4083 3638 | },
|
4084 3639 | }
|
4085 3640 | }
|
4086 3641 | }
|
4087 3642 | }
|
4088 - | /// See [`DateTimeSet`](crate::model::DateTimeSet).
|
4089 - | pub mod date_time_set {
|
3643 + | /// See [`MinLengthString`](crate::model::MinLengthString).
|
3644 + | pub mod min_length_string {
|
4090 3645 |
|
4091 - | #[allow(clippy::enum_variant_names)]
|
4092 3646 | #[derive(Debug, PartialEq)]
|
4093 3647 | pub enum ConstraintViolation {
|
4094 - | /// Constraint violation error when the list does not contain unique items
|
4095 - | UniqueItems {
|
4096 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
4097 - | /// at least two elements.
|
4098 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
4099 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
4100 - | /// Nothing is guaranteed about the order of the indices.
|
4101 - | duplicate_indices: ::std::vec::Vec<usize>,
|
4102 - | /// The original vector, that contains duplicate items.
|
4103 - | original: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
4104 - | },
|
3648 + | /// Error when a string doesn't satisfy its `@length` requirements.
|
3649 + | Length(usize),
|
4105 3650 | }
|
4106 3651 |
|
4107 3652 | impl ::std::fmt::Display for ConstraintViolation {
|
4108 3653 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4109 3654 | let message = match self {
|
4110 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4111 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#DateTimeSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
3655 + | Self::Length(length) => {
|
3656 + | format!("Value with length {} provided for 'aws.protocoltests.restjson.validation#MinLengthString' failed to satisfy constraint: Member must have length greater than or equal to 2", length)
|
3657 + | }
|
4112 3658 | };
|
4113 3659 | write!(f, "{message}")
|
4114 3660 | }
|
4115 3661 | }
|
4116 3662 |
|
4117 3663 | impl ::std::error::Error for ConstraintViolation {}
|
4118 3664 | impl ConstraintViolation {
|
4119 3665 | pub(crate) fn as_validation_exception_field(
|
4120 3666 | self,
|
4121 3667 | path: ::std::string::String,
|
4122 3668 | ) -> crate::model::ValidationExceptionField {
|
4123 3669 | match self {
|
4124 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4125 - | crate::model::ValidationExceptionField {
|
4126 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
3670 + | Self::Length(length) => crate::model::ValidationExceptionField {
|
3671 + | message: format!("Value with length {} at '{}' failed to satisfy constraint: Member must have length greater than or equal to 2", length, &path),
|
4127 3672 | path,
|
4128 3673 | },
|
4129 3674 | }
|
4130 3675 | }
|
4131 3676 | }
|
4132 3677 | }
|
4133 - | /// See [`TimestampSet`](crate::model::TimestampSet).
|
4134 - | pub mod timestamp_set {
|
3678 + | /// See [`MaxLengthString`](crate::model::MaxLengthString).
|
3679 + | pub mod max_length_string {
|
4135 3680 |
|
4136 - | #[allow(clippy::enum_variant_names)]
|
4137 3681 | #[derive(Debug, PartialEq)]
|
4138 3682 | pub enum ConstraintViolation {
|
4139 - | /// Constraint violation error when the list does not contain unique items
|
4140 - | UniqueItems {
|
4141 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
4142 - | /// at least two elements.
|
4143 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
4144 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
4145 - | /// Nothing is guaranteed about the order of the indices.
|
4146 - | duplicate_indices: ::std::vec::Vec<usize>,
|
4147 - | /// The original vector, that contains duplicate items.
|
4148 - | original: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
4149 - | },
|
3683 + | /// Error when a string doesn't satisfy its `@length` requirements.
|
3684 + | Length(usize),
|
4150 3685 | }
|
4151 3686 |
|
4152 3687 | impl ::std::fmt::Display for ConstraintViolation {
|
4153 3688 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4154 3689 | let message = match self {
|
4155 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4156 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#TimestampSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
3690 + | Self::Length(length) => {
|
3691 + | format!("Value with length {} provided for 'aws.protocoltests.restjson.validation#MaxLengthString' failed to satisfy constraint: Member must have length less than or equal to 8", length)
|
3692 + | }
|
4157 3693 | };
|
4158 3694 | write!(f, "{message}")
|
4159 3695 | }
|
4160 3696 | }
|
4161 3697 |
|
4162 3698 | impl ::std::error::Error for ConstraintViolation {}
|
4163 3699 | impl ConstraintViolation {
|
4164 3700 | pub(crate) fn as_validation_exception_field(
|
4165 3701 | self,
|
4166 3702 | path: ::std::string::String,
|
4167 3703 | ) -> crate::model::ValidationExceptionField {
|
4168 3704 | match self {
|
4169 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4170 - | crate::model::ValidationExceptionField {
|
4171 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
3705 + | Self::Length(length) => crate::model::ValidationExceptionField {
|
3706 + | message: format!("Value with length {} at '{}' failed to satisfy constraint: Member must have length less than or equal to 8", length, &path),
|
4172 3707 | path,
|
4173 3708 | },
|
4174 3709 | }
|
4175 3710 | }
|
4176 3711 | }
|
4177 3712 | }
|
4178 - | /// See [`LongSet`](crate::model::LongSet).
|
4179 - | pub mod long_set {
|
3713 + | /// See [`LengthList`](crate::model::LengthList).
|
3714 + | pub mod length_list {
|
4180 3715 |
|
4181 3716 | #[allow(clippy::enum_variant_names)]
|
4182 3717 | #[derive(Debug, PartialEq)]
|
4183 3718 | pub enum ConstraintViolation {
|
4184 - | /// Constraint violation error when the list does not contain unique items
|
4185 - | UniqueItems {
|
4186 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
4187 - | /// at least two elements.
|
4188 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
4189 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
4190 - | /// Nothing is guaranteed about the order of the indices.
|
4191 - | duplicate_indices: ::std::vec::Vec<usize>,
|
4192 - | /// The original vector, that contains duplicate items.
|
4193 - | original: ::std::vec::Vec<i64>,
|
4194 - | },
|
3719 + | /// Constraint violation error when the list doesn't have the required length
|
3720 + | Length(usize),
|
3721 + | /// Constraint violation error when an element doesn't satisfy its own constraints.
|
3722 + | /// The first component of the tuple is the index in the collection where the
|
3723 + | /// first constraint violation was found.
|
3724 + | #[doc(hidden)]
|
3725 + | Member(usize, crate::model::length_string::ConstraintViolation),
|
4195 3726 | }
|
4196 3727 |
|
4197 3728 | impl ::std::fmt::Display for ConstraintViolation {
|
4198 3729 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4199 3730 | let message = match self {
|
4200 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4201 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#LongSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
3731 + | Self::Length(length) => {
|
3732 + | format!("Value with length {} provided for 'aws.protocoltests.restjson.validation#LengthList' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length)
|
3733 + | }
|
3734 + | Self::Member(index, failing_member) => format!(
|
3735 + | "Value at index {index} failed to satisfy constraint. {}",
|
3736 + | failing_member
|
3737 + | ),
|
4202 3738 | };
|
4203 3739 | write!(f, "{message}")
|
4204 3740 | }
|
4205 3741 | }
|
4206 3742 |
|
4207 3743 | impl ::std::error::Error for ConstraintViolation {}
|
4208 3744 | impl ConstraintViolation {
|
4209 3745 | pub(crate) fn as_validation_exception_field(
|
4210 3746 | self,
|
4211 3747 | path: ::std::string::String,
|
4212 3748 | ) -> crate::model::ValidationExceptionField {
|
4213 3749 | match self {
|
4214 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4215 - | crate::model::ValidationExceptionField {
|
4216 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
3750 + | Self::Length(length) => crate::model::ValidationExceptionField {
|
3751 + | message: format!("Value with length {} at '{}' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length, &path),
|
4217 3752 | path,
|
4218 3753 | },
|
3754 + | Self::Member(index, member_constraint_violation) =>
|
3755 + | member_constraint_violation.as_validation_exception_field(path + "/" + &index.to_string())
|
4219 3756 | }
|
4220 3757 | }
|
4221 3758 | }
|
4222 3759 | }
|
4223 - | /// See [`IntegerSet`](crate::model::IntegerSet).
|
4224 - | pub mod integer_set {
|
3760 + | /// See [`LengthMap`](crate::model::LengthMap).
|
3761 + | pub mod length_map {
|
4225 3762 |
|
4226 3763 | #[allow(clippy::enum_variant_names)]
|
4227 3764 | #[derive(Debug, PartialEq)]
|
4228 3765 | pub enum ConstraintViolation {
|
4229 - | /// Constraint violation error when the list does not contain unique items
|
4230 - | UniqueItems {
|
4231 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
4232 - | /// at least two elements.
|
4233 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
4234 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
4235 - | /// Nothing is guaranteed about the order of the indices.
|
4236 - | duplicate_indices: ::std::vec::Vec<usize>,
|
4237 - | /// The original vector, that contains duplicate items.
|
4238 - | original: ::std::vec::Vec<i32>,
|
4239 - | },
|
3766 + | Length(usize),
|
3767 + | #[doc(hidden)]
|
3768 + | Key(crate::model::length_string::ConstraintViolation),
|
3769 + | #[doc(hidden)]
|
3770 + | Value(
|
3771 + | crate::model::LengthString,
|
3772 + | crate::model::length_list::ConstraintViolation,
|
3773 + | ),
|
4240 3774 | }
|
4241 3775 |
|
4242 3776 | impl ::std::fmt::Display for ConstraintViolation {
|
4243 3777 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4244 - | let message = match self {
|
4245 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4246 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#IntegerSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
4247 - | };
|
4248 - | write!(f, "{message}")
|
3778 + | match self {
|
3779 + | Self::Length(length) => {
|
3780 + | write!(f, "Value with length {} provided for 'aws.protocoltests.restjson.validation#LengthMap' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length)
|
3781 + | }
|
3782 + | Self::Key(key_constraint_violation) => write!(f, "{}", key_constraint_violation),
|
3783 + | Self::Value(_, value_constraint_violation) => {
|
3784 + | write!(f, "{}", value_constraint_violation)
|
3785 + | }
|
3786 + | }
|
4249 3787 | }
|
4250 3788 | }
|
4251 3789 |
|
4252 3790 | impl ::std::error::Error for ConstraintViolation {}
|
4253 3791 | impl ConstraintViolation {
|
4254 3792 | pub(crate) fn as_validation_exception_field(
|
4255 3793 | self,
|
4256 3794 | path: ::std::string::String,
|
4257 3795 | ) -> crate::model::ValidationExceptionField {
|
4258 3796 | match self {
|
4259 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4260 - | crate::model::ValidationExceptionField {
|
4261 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
3797 + | Self::Length(length) => crate::model::ValidationExceptionField {
|
3798 + | message: format!("Value with length {} at '{}' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length, &path),
|
4262 3799 | path,
|
4263 3800 | },
|
3801 + | Self::Key(key_constraint_violation) => key_constraint_violation.as_validation_exception_field(path),
|
3802 + | Self::Value(key, value_constraint_violation) => value_constraint_violation.as_validation_exception_field(path + "/" + key.as_str()),
|
4264 3803 | }
|
4265 3804 | }
|
4266 3805 | }
|
4267 3806 | }
|
4268 - | /// See [`ShortSet`](crate::model::ShortSet).
|
4269 - | pub mod short_set {
|
4270 - |
|
4271 - | #[allow(clippy::enum_variant_names)]
|
4272 - | #[derive(Debug, PartialEq)]
|
4273 - | pub enum ConstraintViolation {
|
4274 - | /// Constraint violation error when the list does not contain unique items
|
4275 - | UniqueItems {
|
4276 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
4277 - | /// at least two elements.
|
4278 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
4279 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
4280 - | /// Nothing is guaranteed about the order of the indices.
|
4281 - | duplicate_indices: ::std::vec::Vec<usize>,
|
4282 - | /// The original vector, that contains duplicate items.
|
4283 - | original: ::std::vec::Vec<i16>,
|
4284 - | },
|
3807 + | /// See [`PatternString`](crate::model::PatternString).
|
3808 + | pub mod pattern_string {
|
3809 + |
|
3810 + | #[derive(Debug, PartialEq)]
|
3811 + | pub enum ConstraintViolation {
|
3812 + | /// Error when a string doesn't satisfy its `@pattern`.
|
3813 + | /// Contains the String that failed the pattern.
|
3814 + | Pattern(String),
|
4285 3815 | }
|
4286 3816 |
|
4287 3817 | impl ::std::fmt::Display for ConstraintViolation {
|
4288 3818 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4289 3819 | let message = match self {
|
4290 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4291 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#ShortSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
3820 + | Self::Pattern(_) => {
|
3821 + | format!(
|
3822 + | r#"Value provided for `aws.protocoltests.restjson.validation#PatternString` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
3823 + | r#"^[a-m]+$"#
|
3824 + | )
|
3825 + | }
|
4292 3826 | };
|
4293 3827 | write!(f, "{message}")
|
4294 3828 | }
|
4295 3829 | }
|
4296 3830 |
|
4297 3831 | impl ::std::error::Error for ConstraintViolation {}
|
4298 3832 | impl ConstraintViolation {
|
4299 3833 | pub(crate) fn as_validation_exception_field(
|
4300 3834 | self,
|
4301 3835 | path: ::std::string::String,
|
4302 3836 | ) -> crate::model::ValidationExceptionField {
|
4303 3837 | match self {
|
4304 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4305 - | crate::model::ValidationExceptionField {
|
4306 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
4307 - | path,
|
3838 + | #[allow(unused_variables)]
|
3839 + | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
3840 + | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^[a-m]+$"#),
|
3841 + | path
|
4308 3842 | },
|
4309 3843 | }
|
4310 3844 | }
|
4311 3845 | }
|
4312 3846 | }
|
4313 - | /// See [`ByteSet`](crate::model::ByteSet).
|
4314 - | pub mod byte_set {
|
3847 + | /// See [`EvilString`](crate::model::EvilString).
|
3848 + | pub mod evil_string {
|
4315 3849 |
|
4316 - | #[allow(clippy::enum_variant_names)]
|
4317 3850 | #[derive(Debug, PartialEq)]
|
4318 3851 | pub enum ConstraintViolation {
|
4319 - | /// Constraint violation error when the list does not contain unique items
|
4320 - | UniqueItems {
|
4321 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
4322 - | /// at least two elements.
|
4323 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
4324 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
4325 - | /// Nothing is guaranteed about the order of the indices.
|
4326 - | duplicate_indices: ::std::vec::Vec<usize>,
|
4327 - | /// The original vector, that contains duplicate items.
|
4328 - | original: ::std::vec::Vec<i8>,
|
4329 - | },
|
3852 + | /// Error when a string doesn't satisfy its `@pattern`.
|
3853 + | /// Contains the String that failed the pattern.
|
3854 + | Pattern(String),
|
4330 3855 | }
|
4331 3856 |
|
4332 3857 | impl ::std::fmt::Display for ConstraintViolation {
|
4333 3858 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4334 3859 | let message = match self {
|
4335 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4336 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#ByteSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
3860 + | Self::Pattern(_) => {
|
3861 + | format!(
|
3862 + | r#"Value provided for `aws.protocoltests.restjson.validation#EvilString` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
3863 + | r#"^([0-9]+)+$"#
|
3864 + | )
|
3865 + | }
|
4337 3866 | };
|
4338 3867 | write!(f, "{message}")
|
4339 3868 | }
|
4340 3869 | }
|
4341 3870 |
|
4342 3871 | impl ::std::error::Error for ConstraintViolation {}
|
4343 3872 | impl ConstraintViolation {
|
4344 3873 | pub(crate) fn as_validation_exception_field(
|
4345 3874 | self,
|
4346 3875 | path: ::std::string::String,
|
4347 3876 | ) -> crate::model::ValidationExceptionField {
|
4348 3877 | match self {
|
4349 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4350 - | crate::model::ValidationExceptionField {
|
4351 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
4352 - | path,
|
3878 + | #[allow(unused_variables)]
|
3879 + | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
3880 + | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^([0-9]+)+$"#),
|
3881 + | path
|
4353 3882 | },
|
4354 3883 | }
|
4355 3884 | }
|
4356 3885 | }
|
4357 3886 | }
|
4358 - | /// See [`StringSet`](crate::model::StringSet).
|
4359 - | pub mod string_set {
|
3887 + | pub mod pattern_list {
|
4360 3888 |
|
4361 3889 | #[allow(clippy::enum_variant_names)]
|
4362 3890 | #[derive(Debug, PartialEq)]
|
4363 3891 | pub enum ConstraintViolation {
|
4364 - | /// Constraint violation error when the list does not contain unique items
|
4365 - | UniqueItems {
|
4366 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
4367 - | /// at least two elements.
|
4368 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
4369 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
4370 - | /// Nothing is guaranteed about the order of the indices.
|
4371 - | duplicate_indices: ::std::vec::Vec<usize>,
|
4372 - | /// The original vector, that contains duplicate items.
|
4373 - | original: ::std::vec::Vec<::std::string::String>,
|
4374 - | },
|
3892 + | /// Constraint violation error when an element doesn't satisfy its own constraints.
|
3893 + | /// The first component of the tuple is the index in the collection where the
|
3894 + | /// first constraint violation was found.
|
3895 + | #[doc(hidden)]
|
3896 + | Member(usize, crate::model::pattern_string::ConstraintViolation),
|
4375 3897 | }
|
4376 3898 |
|
4377 3899 | impl ::std::fmt::Display for ConstraintViolation {
|
4378 3900 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4379 3901 | let message = match self {
|
4380 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4381 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#StringSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
3902 + | Self::Member(index, failing_member) => format!(
|
3903 + | "Value at index {index} failed to satisfy constraint. {}",
|
3904 + | failing_member
|
3905 + | ),
|
4382 3906 | };
|
4383 3907 | write!(f, "{message}")
|
4384 3908 | }
|
4385 3909 | }
|
4386 3910 |
|
4387 3911 | impl ::std::error::Error for ConstraintViolation {}
|
4388 3912 | impl ConstraintViolation {
|
4389 3913 | pub(crate) fn as_validation_exception_field(
|
4390 3914 | self,
|
4391 3915 | path: ::std::string::String,
|
4392 3916 | ) -> crate::model::ValidationExceptionField {
|
4393 3917 | match self {
|
4394 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4395 - | crate::model::ValidationExceptionField {
|
4396 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
4397 - | path,
|
4398 - | },
|
3918 + | Self::Member(index, member_constraint_violation) => member_constraint_violation
|
3919 + | .as_validation_exception_field(path + "/" + &index.to_string()),
|
4399 3920 | }
|
4400 3921 | }
|
4401 3922 | }
|
4402 3923 | }
|
4403 - | /// See [`BooleanSet`](crate::model::BooleanSet).
|
4404 - | pub mod boolean_set {
|
3924 + | pub mod pattern_map {
|
4405 3925 |
|
4406 3926 | #[allow(clippy::enum_variant_names)]
|
4407 3927 | #[derive(Debug, PartialEq)]
|
4408 3928 | pub enum ConstraintViolation {
|
4409 - | /// Constraint violation error when the list does not contain unique items
|
4410 - | UniqueItems {
|
4411 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
4412 - | /// at least two elements.
|
4413 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
4414 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
4415 - | /// Nothing is guaranteed about the order of the indices.
|
4416 - | duplicate_indices: ::std::vec::Vec<usize>,
|
4417 - | /// The original vector, that contains duplicate items.
|
4418 - | original: ::std::vec::Vec<bool>,
|
4419 - | },
|
3929 + | #[doc(hidden)]
|
3930 + | Key(crate::model::pattern_string::ConstraintViolation),
|
3931 + | #[doc(hidden)]
|
3932 + | Value(
|
3933 + | crate::model::PatternString,
|
3934 + | crate::model::pattern_string::ConstraintViolation,
|
3935 + | ),
|
4420 3936 | }
|
4421 3937 |
|
4422 3938 | impl ::std::fmt::Display for ConstraintViolation {
|
4423 3939 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4424 - | let message = match self {
|
4425 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4426 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#BooleanSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
4427 - | };
|
4428 - | write!(f, "{message}")
|
3940 + | match self {
|
3941 + | Self::Key(key_constraint_violation) => write!(f, "{}", key_constraint_violation),
|
3942 + | Self::Value(_, value_constraint_violation) => {
|
3943 + | write!(f, "{}", value_constraint_violation)
|
3944 + | }
|
3945 + | }
|
4429 3946 | }
|
4430 3947 | }
|
4431 3948 |
|
4432 3949 | impl ::std::error::Error for ConstraintViolation {}
|
4433 3950 | impl ConstraintViolation {
|
4434 3951 | pub(crate) fn as_validation_exception_field(
|
4435 3952 | self,
|
4436 3953 | path: ::std::string::String,
|
4437 3954 | ) -> crate::model::ValidationExceptionField {
|
4438 3955 | match self {
|
4439 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4440 - | crate::model::ValidationExceptionField {
|
4441 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
4442 - | path,
|
4443 - | },
|
3956 + | Self::Key(key_constraint_violation) => {
|
3957 + | key_constraint_violation.as_validation_exception_field(path)
|
3958 + | }
|
3959 + | Self::Value(key, value_constraint_violation) => value_constraint_violation
|
3960 + | .as_validation_exception_field(path + "/" + key.as_str()),
|
4444 3961 | }
|
4445 3962 | }
|
4446 3963 | }
|
4447 3964 | }
|
4448 - | /// See [`BlobSet`](crate::model::BlobSet).
|
4449 - | pub mod blob_set {
|
3965 + | pub mod pattern_union {
|
4450 3966 |
|
3967 + | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
4451 3968 | #[allow(clippy::enum_variant_names)]
|
4452 - | #[derive(Debug, PartialEq)]
|
4453 3969 | pub enum ConstraintViolation {
|
4454 - | /// Constraint violation error when the list does not contain unique items
|
4455 - | UniqueItems {
|
4456 - | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
4457 - | /// at least two elements.
|
4458 - | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
4459 - | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
4460 - | /// Nothing is guaranteed about the order of the indices.
|
4461 - | duplicate_indices: ::std::vec::Vec<usize>,
|
4462 - | /// The original vector, that contains duplicate items.
|
4463 - | original: ::std::vec::Vec<::aws_smithy_types::Blob>,
|
4464 - | },
|
3970 + | First(crate::model::pattern_string::ConstraintViolation),
|
3971 + | Second(crate::model::pattern_string::ConstraintViolation),
|
4465 3972 | }
|
4466 - |
|
4467 3973 | impl ::std::fmt::Display for ConstraintViolation {
|
4468 3974 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4469 - | let message = match self {
|
4470 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4471 - | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#BlobSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
4472 - | };
|
4473 - | write!(f, "{message}")
|
3975 + | match self {
|
3976 + | Self::First(inner) => write!(f, "{inner}"),
|
3977 + | Self::Second(inner) => write!(f, "{inner}"),
|
3978 + | }
|
4474 3979 | }
|
4475 3980 | }
|
4476 3981 |
|
4477 3982 | impl ::std::error::Error for ConstraintViolation {}
|
4478 3983 | impl ConstraintViolation {
|
4479 3984 | pub(crate) fn as_validation_exception_field(
|
4480 3985 | self,
|
4481 3986 | path: ::std::string::String,
|
4482 3987 | ) -> crate::model::ValidationExceptionField {
|
4483 3988 | match self {
|
4484 - | Self::UniqueItems { duplicate_indices, .. } =>
|
4485 - | crate::model::ValidationExceptionField {
|
4486 - | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
4487 - | path,
|
4488 - | },
|
3989 + | Self::First(inner) => inner.as_validation_exception_field(path + "/first"),
|
3990 + | Self::Second(inner) => inner.as_validation_exception_field(path + "/second"),
|
4489 3991 | }
|
4490 3992 | }
|
4491 3993 | }
|
4492 3994 | }
|
4493 - | /// See [`MaxLong`](crate::model::MaxLong).
|
4494 - | pub mod max_long {
|
3995 + | pub mod pattern_list_override {
|
4495 3996 |
|
3997 + | #[allow(clippy::enum_variant_names)]
|
4496 3998 | #[derive(Debug, PartialEq)]
|
4497 3999 | pub enum ConstraintViolation {
|
4498 - | Range(i64),
|
4000 + | /// Constraint violation error when an element doesn't satisfy its own constraints.
|
4001 + | /// The first component of the tuple is the index in the collection where the
|
4002 + | /// first constraint violation was found.
|
4003 + | #[doc(hidden)]
|
4004 + | Member(
|
4005 + | usize,
|
4006 + | crate::model::pattern_list_override::member::ConstraintViolation,
|
4007 + | ),
|
4499 4008 | }
|
4500 4009 |
|
4501 4010 | impl ::std::fmt::Display for ConstraintViolation {
|
4502 4011 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4503 - | write!(f, "Value for `aws.protocoltests.restjson.validation#MaxLong`failed to satisfy constraint: Member must be less than or equal to 8")
|
4012 + | let message = match self {
|
4013 + | Self::Member(index, failing_member) => format!(
|
4014 + | "Value at index {index} failed to satisfy constraint. {}",
|
4015 + | failing_member
|
4016 + | ),
|
4017 + | };
|
4018 + | write!(f, "{message}")
|
4504 4019 | }
|
4505 4020 | }
|
4506 4021 |
|
4507 4022 | impl ::std::error::Error for ConstraintViolation {}
|
4508 4023 | impl ConstraintViolation {
|
4509 4024 | pub(crate) fn as_validation_exception_field(
|
4510 4025 | self,
|
4511 4026 | path: ::std::string::String,
|
4512 4027 | ) -> crate::model::ValidationExceptionField {
|
4513 4028 | match self {
|
4514 - | Self::Range(_) => crate::model::ValidationExceptionField {
|
4515 - | message: format!("Value at '{}' failed to satisfy constraint: Member must be less than or equal to 8", &path),
|
4516 - | path,
|
4517 - | },
|
4029 + | Self::Member(index, member_constraint_violation) => member_constraint_violation
|
4030 + | .as_validation_exception_field(path + "/" + &index.to_string()),
|
4031 + | }
|
4032 + | }
|
4033 + | }
|
4034 + | #[allow(missing_docs)] // documentation missing in model
|
4035 + | ///
|
4036 + | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
4037 + | /// [constraint traits]. Use [`Member::try_from`] to construct values of this type.
|
4038 + | ///
|
4039 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
4040 + | ///
|
4041 + | #[derive(
|
4042 + | ::std::clone::Clone,
|
4043 + | ::std::cmp::Eq,
|
4044 + | ::std::cmp::PartialEq,
|
4045 + | ::std::fmt::Debug,
|
4046 + | ::std::hash::Hash,
|
4047 + | )]
|
4048 + | pub struct Member(pub(crate) ::std::string::String);
|
4049 + | impl Member {
|
4050 + | /// Extracts a string slice containing the entire underlying `String`.
|
4051 + | pub fn as_str(&self) -> &str {
|
4052 + | &self.0
|
4053 + | }
|
4054 + |
|
4055 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
4056 + | pub fn inner(&self) -> &::std::string::String {
|
4057 + | &self.0
|
4058 + | }
|
4059 + |
|
4060 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
4061 + | pub fn into_inner(self) -> ::std::string::String {
|
4062 + | self.0
|
4063 + | }
|
4064 + | }
|
4065 + | impl Member {
|
4066 + | fn check_pattern(
|
4067 + | string: ::std::string::String,
|
4068 + | ) -> ::std::result::Result<
|
4069 + | ::std::string::String,
|
4070 + | crate::model::pattern_list_override::member::ConstraintViolation,
|
4071 + | > {
|
4072 + | let regex = Self::compile_regex();
|
4073 + |
|
4074 + | if regex.is_match(&string) {
|
4075 + | Ok(string)
|
4076 + | } else {
|
4077 + | Err(
|
4078 + | crate::model::pattern_list_override::member::ConstraintViolation::Pattern(
|
4079 + | string,
|
4080 + | ),
|
4081 + | )
|
4082 + | }
|
4083 + | }
|
4084 + |
|
4085 + | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
4086 + | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
4087 + | pub fn compile_regex() -> &'static ::regex::Regex {
|
4088 + | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
4089 + | ::regex::Regex::new(r#"^[g-m]+$"#).expect(r#"The regular expression ^[g-m]+$ is not supported by the `regex` crate; feel free to file an issue under https://github.com/smithy-lang/smithy-rs/issues for support"#)
|
4090 + | });
|
4091 + |
|
4092 + | ®EX
|
4093 + | }
|
4094 + | }
|
4095 + | impl ::std::convert::TryFrom<::std::string::String> for Member {
|
4096 + | type Error = crate::model::pattern_list_override::member::ConstraintViolation;
|
4097 + |
|
4098 + | /// Constructs a `Member` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
4099 + | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
4100 + | let value = Self::check_pattern(value)?;
|
4101 + |
|
4102 + | Ok(Self(value))
|
4518 4103 | }
|
4519 4104 | }
|
4105 + | impl crate::constrained::Constrained for Member {
|
4106 + | type Unconstrained = ::std::string::String;
|
4520 4107 | }
|
4521 - | }
|
4522 - | /// See [`MinLong`](crate::model::MinLong).
|
4523 - | pub mod min_long {
|
4524 4108 |
|
4525 - | #[derive(Debug, PartialEq)]
|
4526 - | pub enum ConstraintViolation {
|
4527 - | Range(i64),
|
4109 + | impl ::std::convert::From<::std::string::String>
|
4110 + | for crate::constrained::MaybeConstrained<crate::model::pattern_list_override::Member>
|
4111 + | {
|
4112 + | fn from(value: ::std::string::String) -> Self {
|
4113 + | Self::Unconstrained(value)
|
4114 + | }
|
4528 4115 | }
|
4529 4116 |
|
4530 - | impl ::std::fmt::Display for ConstraintViolation {
|
4117 + | impl ::std::fmt::Display for Member {
|
4531 4118 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4532 - | write!(f, "Value for `aws.protocoltests.restjson.validation#MinLong`failed to satisfy constraint: Member must be greater than or equal to 2")
|
4119 + | self.0.fmt(f)
|
4533 4120 | }
|
4534 4121 | }
|
4535 4122 |
|
4536 - | impl ::std::error::Error for ConstraintViolation {}
|
4537 - | impl ConstraintViolation {
|
4538 - | pub(crate) fn as_validation_exception_field(
|
4539 - | self,
|
4540 - | path: ::std::string::String,
|
4541 - | ) -> crate::model::ValidationExceptionField {
|
4542 - | match self {
|
4543 - | Self::Range(_) => crate::model::ValidationExceptionField {
|
4544 - | message: format!("Value at '{}' failed to satisfy constraint: Member must be greater than or equal to 2", &path),
|
4545 - | path,
|
4546 - | },
|
4123 + | impl ::std::convert::From<Member> for ::std::string::String {
|
4124 + | fn from(value: Member) -> Self {
|
4125 + | value.into_inner()
|
4126 + | }
|
4547 4127 | }
|
4128 + | #[cfg(test)]
|
4129 + | mod test_member {
|
4130 + | #[test]
|
4131 + | fn regex_compiles() {
|
4132 + | crate::model::pattern_list_override::Member::compile_regex();
|
4548 4133 | }
|
4549 4134 | }
|
4550 - | }
|
4551 - | /// See [`RangeLong`](crate::model::RangeLong).
|
4552 - | pub mod range_long {
|
4135 + |
|
4136 + | /// See [`PatternListOverrideMember`](crate::model::pattern_list_override::Member).
|
4137 + | pub mod member {
|
4553 4138 |
|
4554 4139 | #[derive(Debug, PartialEq)]
|
4555 4140 | pub enum ConstraintViolation {
|
4556 - | Range(i64),
|
4141 + | /// Error when a string doesn't satisfy its `@pattern`.
|
4142 + | /// Contains the String that failed the pattern.
|
4143 + | Pattern(String),
|
4557 4144 | }
|
4558 4145 |
|
4559 4146 | impl ::std::fmt::Display for ConstraintViolation {
|
4560 4147 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4561 - | write!(f, "Value for `aws.protocoltests.restjson.validation#RangeLong`failed to satisfy constraint: Member must be between 2 and 8, inclusive")
|
4148 + | let message = match self {
|
4149 + | Self::Pattern(_) => {
|
4150 + | format!(
|
4151 + | r#"Value provided for `aws.protocoltests.restjson.validation#PatternListOverrideMember` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
4152 + | r#"^[g-m]+$"#
|
4153 + | )
|
4154 + | }
|
4155 + | };
|
4156 + | write!(f, "{message}")
|
4562 4157 | }
|
4563 4158 | }
|
4564 4159 |
|
4565 4160 | impl ::std::error::Error for ConstraintViolation {}
|
4566 4161 | impl ConstraintViolation {
|
4567 4162 | pub(crate) fn as_validation_exception_field(
|
4568 4163 | self,
|
4569 4164 | path: ::std::string::String,
|
4570 4165 | ) -> crate::model::ValidationExceptionField {
|
4571 4166 | match self {
|
4572 - | Self::Range(_) => crate::model::ValidationExceptionField {
|
4573 - | message: format!("Value at '{}' failed to satisfy constraint: Member must be between 2 and 8, inclusive", &path),
|
4574 - | path,
|
4167 + | #[allow(unused_variables)]
|
4168 + | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
4169 + | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^[g-m]+$"#),
|
4170 + | path
|
4575 4171 | },
|
4576 4172 | }
|
4577 4173 | }
|
4578 4174 | }
|
4175 + | }
|
4579 4176 | }
|
4580 - | /// See [`MaxInteger`](crate::model::MaxInteger).
|
4581 - | pub mod max_integer {
|
4177 + | pub mod pattern_map_override {
|
4582 4178 |
|
4179 + | #[allow(clippy::enum_variant_names)]
|
4583 4180 | #[derive(Debug, PartialEq)]
|
4584 4181 | pub enum ConstraintViolation {
|
4585 - | Range(i32),
|
4182 + | #[doc(hidden)]
|
4183 + | Key(crate::model::pattern_map_override::key::ConstraintViolation),
|
4184 + | #[doc(hidden)]
|
4185 + | Value(
|
4186 + | crate::model::pattern_map_override::Key,
|
4187 + | crate::model::pattern_map_override::value::ConstraintViolation,
|
4188 + | ),
|
4586 4189 | }
|
4587 4190 |
|
4588 4191 | impl ::std::fmt::Display for ConstraintViolation {
|
4589 4192 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4590 - | write!(f, "Value for `aws.protocoltests.restjson.validation#MaxInteger`failed to satisfy constraint: Member must be less than or equal to 8")
|
4193 + | match self {
|
4194 + | Self::Key(key_constraint_violation) => write!(f, "{}", key_constraint_violation),
|
4195 + | Self::Value(_, value_constraint_violation) => {
|
4196 + | write!(f, "{}", value_constraint_violation)
|
4197 + | }
|
4198 + | }
|
4591 4199 | }
|
4592 4200 | }
|
4593 4201 |
|
4594 4202 | impl ::std::error::Error for ConstraintViolation {}
|
4595 4203 | impl ConstraintViolation {
|
4596 4204 | pub(crate) fn as_validation_exception_field(
|
4597 4205 | self,
|
4598 4206 | path: ::std::string::String,
|
4599 4207 | ) -> crate::model::ValidationExceptionField {
|
4600 4208 | match self {
|
4601 - | Self::Range(_) => crate::model::ValidationExceptionField {
|
4602 - | message: format!("Value at '{}' failed to satisfy constraint: Member must be less than or equal to 8", &path),
|
4603 - | path,
|
4604 - | },
|
4209 + | Self::Key(key_constraint_violation) => {
|
4210 + | key_constraint_violation.as_validation_exception_field(path)
|
4211 + | }
|
4212 + | Self::Value(key, value_constraint_violation) => value_constraint_violation
|
4213 + | .as_validation_exception_field(path + "/" + key.as_str()),
|
4605 4214 | }
|
4606 4215 | }
|
4607 4216 | }
|
4608 - | }
|
4609 - | /// See [`MinInteger`](crate::model::MinInteger).
|
4610 - | pub mod min_integer {
|
4217 + | #[allow(missing_docs)] // documentation missing in model
|
4218 + | ///
|
4219 + | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
4220 + | /// [constraint traits]. Use [`Key::try_from`] to construct values of this type.
|
4221 + | ///
|
4222 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
4223 + | ///
|
4224 + | #[derive(
|
4225 + | ::std::clone::Clone,
|
4226 + | ::std::cmp::Eq,
|
4227 + | ::std::cmp::PartialEq,
|
4228 + | ::std::fmt::Debug,
|
4229 + | ::std::hash::Hash,
|
4230 + | )]
|
4231 + | pub struct Key(pub(crate) ::std::string::String);
|
4232 + | impl Key {
|
4233 + | /// Extracts a string slice containing the entire underlying `String`.
|
4234 + | pub fn as_str(&self) -> &str {
|
4235 + | &self.0
|
4236 + | }
|
4611 4237 |
|
4612 - | #[derive(Debug, PartialEq)]
|
4613 - | pub enum ConstraintViolation {
|
4614 - | Range(i32),
|
4238 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
4239 + | pub fn inner(&self) -> &::std::string::String {
|
4240 + | &self.0
|
4615 4241 | }
|
4616 4242 |
|
4617 - | impl ::std::fmt::Display for ConstraintViolation {
|
4618 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4619 - | write!(f, "Value for `aws.protocoltests.restjson.validation#MinInteger`failed to satisfy constraint: Member must be greater than or equal to 2")
|
4243 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
4244 + | pub fn into_inner(self) -> ::std::string::String {
|
4245 + | self.0
|
4620 4246 | }
|
4621 4247 | }
|
4248 + | impl Key {
|
4249 + | fn check_pattern(
|
4250 + | string: ::std::string::String,
|
4251 + | ) -> ::std::result::Result<
|
4252 + | ::std::string::String,
|
4253 + | crate::model::pattern_map_override::key::ConstraintViolation,
|
4254 + | > {
|
4255 + | let regex = Self::compile_regex();
|
4622 4256 |
|
4623 - | impl ::std::error::Error for ConstraintViolation {}
|
4624 - | impl ConstraintViolation {
|
4625 - | pub(crate) fn as_validation_exception_field(
|
4626 - | self,
|
4627 - | path: ::std::string::String,
|
4628 - | ) -> crate::model::ValidationExceptionField {
|
4629 - | match self {
|
4630 - | Self::Range(_) => crate::model::ValidationExceptionField {
|
4631 - | message: format!("Value at '{}' failed to satisfy constraint: Member must be greater than or equal to 2", &path),
|
4632 - | path,
|
4633 - | },
|
4634 - | }
|
4257 + | if regex.is_match(&string) {
|
4258 + | Ok(string)
|
4259 + | } else {
|
4260 + | Err(crate::model::pattern_map_override::key::ConstraintViolation::Pattern(string))
|
4635 4261 | }
|
4636 4262 | }
|
4637 - | }
|
4638 - | /// See [`RangeInteger`](crate::model::RangeInteger).
|
4639 - | pub mod range_integer {
|
4640 4263 |
|
4641 - | #[derive(Debug, PartialEq)]
|
4642 - | pub enum ConstraintViolation {
|
4643 - | Range(i32),
|
4644 - | }
|
4264 + | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
4265 + | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
4266 + | pub fn compile_regex() -> &'static ::regex::Regex {
|
4267 + | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
4268 + | ::regex::Regex::new(r#"^[g-m]+$"#).expect(r#"The regular expression ^[g-m]+$ is not supported by the `regex` crate; feel free to file an issue under https://github.com/smithy-lang/smithy-rs/issues for support"#)
|
4269 + | });
|
4645 4270 |
|
4646 - | impl ::std::fmt::Display for ConstraintViolation {
|
4647 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4648 - | write!(f, "Value for `aws.protocoltests.restjson.validation#RangeInteger`failed to satisfy constraint: Member must be between 2 and 8, inclusive")
|
4271 + | ®EX
|
4649 4272 | }
|
4650 4273 | }
|
4274 + | impl ::std::convert::TryFrom<::std::string::String> for Key {
|
4275 + | type Error = crate::model::pattern_map_override::key::ConstraintViolation;
|
4651 4276 |
|
4652 - | impl ::std::error::Error for ConstraintViolation {}
|
4653 - | impl ConstraintViolation {
|
4654 - | pub(crate) fn as_validation_exception_field(
|
4655 - | self,
|
4656 - | path: ::std::string::String,
|
4657 - | ) -> crate::model::ValidationExceptionField {
|
4658 - | match self {
|
4659 - | Self::Range(_) => crate::model::ValidationExceptionField {
|
4660 - | message: format!("Value at '{}' failed to satisfy constraint: Member must be between 2 and 8, inclusive", &path),
|
4661 - | path,
|
4662 - | },
|
4277 + | /// Constructs a `Key` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
4278 + | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
4279 + | let value = Self::check_pattern(value)?;
|
4280 + |
|
4281 + | Ok(Self(value))
|
4663 4282 | }
|
4664 4283 | }
|
4284 + | impl crate::constrained::Constrained for Key {
|
4285 + | type Unconstrained = ::std::string::String;
|
4665 4286 | }
|
4666 - | }
|
4667 - | /// See [`MaxShort`](crate::model::MaxShort).
|
4668 - | pub mod max_short {
|
4669 4287 |
|
4670 - | #[derive(Debug, PartialEq)]
|
4671 - | pub enum ConstraintViolation {
|
4672 - | Range(i16),
|
4288 + | impl ::std::convert::From<::std::string::String>
|
4289 + | for crate::constrained::MaybeConstrained<crate::model::pattern_map_override::Key>
|
4290 + | {
|
4291 + | fn from(value: ::std::string::String) -> Self {
|
4292 + | Self::Unconstrained(value)
|
4293 + | }
|
4673 4294 | }
|
4674 4295 |
|
4675 - | impl ::std::fmt::Display for ConstraintViolation {
|
4296 + | impl ::std::fmt::Display for Key {
|
4676 4297 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4677 - | write!(f, "Value for `aws.protocoltests.restjson.validation#MaxShort`failed to satisfy constraint: Member must be less than or equal to 8")
|
4298 + | self.0.fmt(f)
|
4678 4299 | }
|
4679 4300 | }
|
4680 4301 |
|
4681 - | impl ::std::error::Error for ConstraintViolation {}
|
4682 - | impl ConstraintViolation {
|
4683 - | pub(crate) fn as_validation_exception_field(
|
4684 - | self,
|
4685 - | path: ::std::string::String,
|
4686 - | ) -> crate::model::ValidationExceptionField {
|
4687 - | match self {
|
4688 - | Self::Range(_) => crate::model::ValidationExceptionField {
|
4689 - | message: format!("Value at '{}' failed to satisfy constraint: Member must be less than or equal to 8", &path),
|
4690 - | path,
|
4691 - | },
|
4302 + | impl ::std::convert::From<Key> for ::std::string::String {
|
4303 + | fn from(value: Key) -> Self {
|
4304 + | value.into_inner()
|
4305 + | }
|
4306 + | }
|
4307 + | #[cfg(test)]
|
4308 + | mod test_key {
|
4309 + | #[test]
|
4310 + | fn regex_compiles() {
|
4311 + | crate::model::pattern_map_override::Key::compile_regex();
|
4692 4312 | }
|
4693 4313 | }
|
4314 + | #[allow(missing_docs)] // documentation missing in model
|
4315 + | ///
|
4316 + | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
4317 + | /// [constraint traits]. Use [`Value::try_from`] to construct values of this type.
|
4318 + | ///
|
4319 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
4320 + | ///
|
4321 + | #[derive(
|
4322 + | ::std::clone::Clone,
|
4323 + | ::std::cmp::Eq,
|
4324 + | ::std::cmp::PartialEq,
|
4325 + | ::std::fmt::Debug,
|
4326 + | ::std::hash::Hash,
|
4327 + | )]
|
4328 + | pub struct Value(pub(crate) ::std::string::String);
|
4329 + | impl Value {
|
4330 + | /// Extracts a string slice containing the entire underlying `String`.
|
4331 + | pub fn as_str(&self) -> &str {
|
4332 + | &self.0
|
4694 4333 | }
|
4695 - | }
|
4696 - | /// See [`MinShort`](crate::model::MinShort).
|
4697 - | pub mod min_short {
|
4698 4334 |
|
4699 - | #[derive(Debug, PartialEq)]
|
4700 - | pub enum ConstraintViolation {
|
4701 - | Range(i16),
|
4335 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
4336 + | pub fn inner(&self) -> &::std::string::String {
|
4337 + | &self.0
|
4702 4338 | }
|
4703 4339 |
|
4704 - | impl ::std::fmt::Display for ConstraintViolation {
|
4705 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4706 - | write!(f, "Value for `aws.protocoltests.restjson.validation#MinShort`failed to satisfy constraint: Member must be greater than or equal to 2")
|
4340 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
4341 + | pub fn into_inner(self) -> ::std::string::String {
|
4342 + | self.0
|
4707 4343 | }
|
4708 4344 | }
|
4345 + | impl Value {
|
4346 + | fn check_pattern(
|
4347 + | string: ::std::string::String,
|
4348 + | ) -> ::std::result::Result<
|
4349 + | ::std::string::String,
|
4350 + | crate::model::pattern_map_override::value::ConstraintViolation,
|
4351 + | > {
|
4352 + | let regex = Self::compile_regex();
|
4709 4353 |
|
4710 - | impl ::std::error::Error for ConstraintViolation {}
|
4711 - | impl ConstraintViolation {
|
4712 - | pub(crate) fn as_validation_exception_field(
|
4713 - | self,
|
4714 - | path: ::std::string::String,
|
4715 - | ) -> crate::model::ValidationExceptionField {
|
4716 - | match self {
|
4717 - | Self::Range(_) => crate::model::ValidationExceptionField {
|
4718 - | message: format!("Value at '{}' failed to satisfy constraint: Member must be greater than or equal to 2", &path),
|
4719 - | path,
|
4720 - | },
|
4721 - | }
|
4354 + | if regex.is_match(&string) {
|
4355 + | Ok(string)
|
4356 + | } else {
|
4357 + | Err(crate::model::pattern_map_override::value::ConstraintViolation::Pattern(string))
|
4722 4358 | }
|
4723 4359 | }
|
4724 - | }
|
4725 - | /// See [`RangeShort`](crate::model::RangeShort).
|
4726 - | pub mod range_short {
|
4727 4360 |
|
4728 - | #[derive(Debug, PartialEq)]
|
4729 - | pub enum ConstraintViolation {
|
4730 - | Range(i16),
|
4731 - | }
|
4361 + | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
4362 + | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
4363 + | pub fn compile_regex() -> &'static ::regex::Regex {
|
4364 + | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
4365 + | ::regex::Regex::new(r#"^[g-m]+$"#).expect(r#"The regular expression ^[g-m]+$ is not supported by the `regex` crate; feel free to file an issue under https://github.com/smithy-lang/smithy-rs/issues for support"#)
|
4366 + | });
|
4732 4367 |
|
4733 - | impl ::std::fmt::Display for ConstraintViolation {
|
4734 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4735 - | write!(f, "Value for `aws.protocoltests.restjson.validation#RangeShort`failed to satisfy constraint: Member must be between 2 and 8, inclusive")
|
4368 + | ®EX
|
4736 4369 | }
|
4737 4370 | }
|
4371 + | impl ::std::convert::TryFrom<::std::string::String> for Value {
|
4372 + | type Error = crate::model::pattern_map_override::value::ConstraintViolation;
|
4738 4373 |
|
4739 - | impl ::std::error::Error for ConstraintViolation {}
|
4740 - | impl ConstraintViolation {
|
4741 - | pub(crate) fn as_validation_exception_field(
|
4742 - | self,
|
4743 - | path: ::std::string::String,
|
4744 - | ) -> crate::model::ValidationExceptionField {
|
4745 - | match self {
|
4746 - | Self::Range(_) => crate::model::ValidationExceptionField {
|
4747 - | message: format!("Value at '{}' failed to satisfy constraint: Member must be between 2 and 8, inclusive", &path),
|
4748 - | path,
|
4749 - | },
|
4374 + | /// Constructs a `Value` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
4375 + | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
4376 + | let value = Self::check_pattern(value)?;
|
4377 + |
|
4378 + | Ok(Self(value))
|
4750 4379 | }
|
4751 4380 | }
|
4381 + | impl crate::constrained::Constrained for Value {
|
4382 + | type Unconstrained = ::std::string::String;
|
4752 4383 | }
|
4753 - | }
|
4754 - | /// See [`MaxByte`](crate::model::MaxByte).
|
4755 - | pub mod max_byte {
|
4756 4384 |
|
4757 - | #[derive(Debug, PartialEq)]
|
4758 - | pub enum ConstraintViolation {
|
4759 - | Range(i8),
|
4385 + | impl ::std::convert::From<::std::string::String>
|
4386 + | for crate::constrained::MaybeConstrained<crate::model::pattern_map_override::Value>
|
4387 + | {
|
4388 + | fn from(value: ::std::string::String) -> Self {
|
4389 + | Self::Unconstrained(value)
|
4390 + | }
|
4760 4391 | }
|
4761 4392 |
|
4762 - | impl ::std::fmt::Display for ConstraintViolation {
|
4393 + | impl ::std::fmt::Display for Value {
|
4763 4394 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4764 - | write!(f, "Value for `aws.protocoltests.restjson.validation#MaxByte`failed to satisfy constraint: Member must be less than or equal to 8")
|
4395 + | self.0.fmt(f)
|
4765 4396 | }
|
4766 4397 | }
|
4767 4398 |
|
4768 - | impl ::std::error::Error for ConstraintViolation {}
|
4769 - | impl ConstraintViolation {
|
4770 - | pub(crate) fn as_validation_exception_field(
|
4771 - | self,
|
4772 - | path: ::std::string::String,
|
4773 - | ) -> crate::model::ValidationExceptionField {
|
4774 - | match self {
|
4775 - | Self::Range(_) => crate::model::ValidationExceptionField {
|
4776 - | message: format!("Value at '{}' failed to satisfy constraint: Member must be less than or equal to 8", &path),
|
4777 - | path,
|
4778 - | },
|
4399 + | impl ::std::convert::From<Value> for ::std::string::String {
|
4400 + | fn from(value: Value) -> Self {
|
4401 + | value.into_inner()
|
4402 + | }
|
4779 4403 | }
|
4404 + | #[cfg(test)]
|
4405 + | mod test_value {
|
4406 + | #[test]
|
4407 + | fn regex_compiles() {
|
4408 + | crate::model::pattern_map_override::Value::compile_regex();
|
4780 4409 | }
|
4781 4410 | }
|
4782 - | }
|
4783 - | /// See [`MinByte`](crate::model::MinByte).
|
4784 - | pub mod min_byte {
|
4411 + |
|
4412 + | /// See [`PatternMapOverrideKey`](crate::model::pattern_map_override::Key).
|
4413 + | pub mod key {
|
4785 4414 |
|
4786 4415 | #[derive(Debug, PartialEq)]
|
4787 4416 | pub enum ConstraintViolation {
|
4788 - | Range(i8),
|
4417 + | /// Error when a string doesn't satisfy its `@pattern`.
|
4418 + | /// Contains the String that failed the pattern.
|
4419 + | Pattern(String),
|
4789 4420 | }
|
4790 4421 |
|
4791 4422 | impl ::std::fmt::Display for ConstraintViolation {
|
4792 4423 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4793 - | write!(f, "Value for `aws.protocoltests.restjson.validation#MinByte`failed to satisfy constraint: Member must be greater than or equal to 2")
|
4424 + | let message = match self {
|
4425 + | Self::Pattern(_) => {
|
4426 + | format!(
|
4427 + | r#"Value provided for `aws.protocoltests.restjson.validation#PatternMapOverrideKey` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
4428 + | r#"^[g-m]+$"#
|
4429 + | )
|
4430 + | }
|
4431 + | };
|
4432 + | write!(f, "{message}")
|
4794 4433 | }
|
4795 4434 | }
|
4796 4435 |
|
4797 4436 | impl ::std::error::Error for ConstraintViolation {}
|
4798 4437 | impl ConstraintViolation {
|
4799 4438 | pub(crate) fn as_validation_exception_field(
|
4800 4439 | self,
|
4801 4440 | path: ::std::string::String,
|
4802 4441 | ) -> crate::model::ValidationExceptionField {
|
4803 4442 | match self {
|
4804 - | Self::Range(_) => crate::model::ValidationExceptionField {
|
4805 - | message: format!("Value at '{}' failed to satisfy constraint: Member must be greater than or equal to 2", &path),
|
4806 - | path,
|
4443 + | #[allow(unused_variables)]
|
4444 + | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
4445 + | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^[g-m]+$"#),
|
4446 + | path
|
4807 4447 | },
|
4808 4448 | }
|
4809 4449 | }
|
4810 4450 | }
|
4811 - | }
|
4812 - | /// See [`RangeByte`](crate::model::RangeByte).
|
4813 - | pub mod range_byte {
|
4451 + | }
|
4452 + | /// See [`PatternMapOverrideValue`](crate::model::pattern_map_override::Value).
|
4453 + | pub mod value {
|
4814 4454 |
|
4815 4455 | #[derive(Debug, PartialEq)]
|
4816 4456 | pub enum ConstraintViolation {
|
4817 - | Range(i8),
|
4457 + | /// Error when a string doesn't satisfy its `@pattern`.
|
4458 + | /// Contains the String that failed the pattern.
|
4459 + | Pattern(String),
|
4818 4460 | }
|
4819 4461 |
|
4820 4462 | impl ::std::fmt::Display for ConstraintViolation {
|
4821 4463 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4822 - | write!(f, "Value for `aws.protocoltests.restjson.validation#RangeByte`failed to satisfy constraint: Member must be between 2 and 8, inclusive")
|
4464 + | let message = match self {
|
4465 + | Self::Pattern(_) => {
|
4466 + | format!(
|
4467 + | r#"Value provided for `aws.protocoltests.restjson.validation#PatternMapOverrideValue` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
4468 + | r#"^[g-m]+$"#
|
4469 + | )
|
4470 + | }
|
4471 + | };
|
4472 + | write!(f, "{message}")
|
4823 4473 | }
|
4824 4474 | }
|
4825 4475 |
|
4826 4476 | impl ::std::error::Error for ConstraintViolation {}
|
4827 4477 | impl ConstraintViolation {
|
4828 4478 | pub(crate) fn as_validation_exception_field(
|
4829 4479 | self,
|
4830 4480 | path: ::std::string::String,
|
4831 4481 | ) -> crate::model::ValidationExceptionField {
|
4832 4482 | match self {
|
4833 - | Self::Range(_) => crate::model::ValidationExceptionField {
|
4834 - | message: format!("Value at '{}' failed to satisfy constraint: Member must be between 2 and 8, inclusive", &path),
|
4835 - | path,
|
4483 + | #[allow(unused_variables)]
|
4484 + | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
4485 + | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^[g-m]+$"#),
|
4486 + | path
|
4836 4487 | },
|
4837 4488 | }
|
4838 4489 | }
|
4839 4490 | }
|
4491 + | }
|
4840 4492 | }
|
4841 4493 | pub mod pattern_union_override {
|
4842 4494 |
|
4843 4495 | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
4844 4496 | #[allow(clippy::enum_variant_names)]
|
4845 4497 | pub enum ConstraintViolation {
|
4846 4498 | First(crate::model::pattern_union_override::first::ConstraintViolation),
|
4847 4499 | Second(crate::model::pattern_union_override::second::ConstraintViolation),
|
4848 4500 | }
|
4849 4501 | impl ::std::fmt::Display for ConstraintViolation {
|
4850 4502 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4851 4503 | match self {
|
4852 4504 | Self::First(inner) => write!(f, "{inner}"),
|
4853 4505 | Self::Second(inner) => write!(f, "{inner}"),
|
4854 4506 | }
|
4855 4507 | }
|
4856 4508 | }
|
4857 4509 |
|
4858 4510 | impl ::std::error::Error for ConstraintViolation {}
|
4859 4511 | impl ConstraintViolation {
|
4860 4512 | pub(crate) fn as_validation_exception_field(
|
4861 4513 | self,
|
4862 4514 | path: ::std::string::String,
|
4863 4515 | ) -> crate::model::ValidationExceptionField {
|
4864 4516 | match self {
|
4865 4517 | Self::First(inner) => inner.as_validation_exception_field(path + "/first"),
|
4866 4518 | Self::Second(inner) => inner.as_validation_exception_field(path + "/second"),
|
4867 4519 | }
|
4868 4520 | }
|
4869 4521 | }
|
4870 4522 | #[allow(missing_docs)] // documentation missing in model
|
4871 4523 | ///
|
4872 4524 | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
4525 + | /// [constraint traits]. Use [`First::try_from`] to construct values of this type.
|
4526 + | ///
|
4527 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
4528 + | ///
|
4529 + | #[derive(
|
4530 + | ::std::clone::Clone,
|
4531 + | ::std::cmp::Eq,
|
4532 + | ::std::cmp::PartialEq,
|
4533 + | ::std::fmt::Debug,
|
4534 + | ::std::hash::Hash,
|
4535 + | )]
|
4536 + | pub struct First(pub(crate) ::std::string::String);
|
4537 + | impl First {
|
4538 + | /// Extracts a string slice containing the entire underlying `String`.
|
4539 + | pub fn as_str(&self) -> &str {
|
4540 + | &self.0
|
4541 + | }
|
4542 + |
|
4543 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
4544 + | pub fn inner(&self) -> &::std::string::String {
|
4545 + | &self.0
|
4546 + | }
|
4547 + |
|
4548 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
4549 + | pub fn into_inner(self) -> ::std::string::String {
|
4550 + | self.0
|
4551 + | }
|
4552 + | }
|
4553 + | impl First {
|
4554 + | fn check_pattern(
|
4555 + | string: ::std::string::String,
|
4556 + | ) -> ::std::result::Result<
|
4557 + | ::std::string::String,
|
4558 + | crate::model::pattern_union_override::first::ConstraintViolation,
|
4559 + | > {
|
4560 + | let regex = Self::compile_regex();
|
4561 + |
|
4562 + | if regex.is_match(&string) {
|
4563 + | Ok(string)
|
4564 + | } else {
|
4565 + | Err(
|
4566 + | crate::model::pattern_union_override::first::ConstraintViolation::Pattern(
|
4567 + | string,
|
4568 + | ),
|
4569 + | )
|
4570 + | }
|
4571 + | }
|
4572 + |
|
4573 + | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
4574 + | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
4575 + | pub fn compile_regex() -> &'static ::regex::Regex {
|
4576 + | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
4577 + | ::regex::Regex::new(r#"^[g-m]+$"#).expect(r#"The regular expression ^[g-m]+$ is not supported by the `regex` crate; feel free to file an issue under https://github.com/smithy-lang/smithy-rs/issues for support"#)
|
4578 + | });
|
4579 + |
|
4580 + | ®EX
|
4581 + | }
|
4582 + | }
|
4583 + | impl ::std::convert::TryFrom<::std::string::String> for First {
|
4584 + | type Error = crate::model::pattern_union_override::first::ConstraintViolation;
|
4585 + |
|
4586 + | /// Constructs a `First` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
4587 + | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
4588 + | let value = Self::check_pattern(value)?;
|
4589 + |
|
4590 + | Ok(Self(value))
|
4591 + | }
|
4592 + | }
|
4593 + | impl crate::constrained::Constrained for First {
|
4594 + | type Unconstrained = ::std::string::String;
|
4595 + | }
|
4596 + |
|
4597 + | impl ::std::convert::From<::std::string::String>
|
4598 + | for crate::constrained::MaybeConstrained<crate::model::pattern_union_override::First>
|
4599 + | {
|
4600 + | fn from(value: ::std::string::String) -> Self {
|
4601 + | Self::Unconstrained(value)
|
4602 + | }
|
4603 + | }
|
4604 + |
|
4605 + | impl ::std::fmt::Display for First {
|
4606 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4607 + | self.0.fmt(f)
|
4608 + | }
|
4609 + | }
|
4610 + |
|
4611 + | impl ::std::convert::From<First> for ::std::string::String {
|
4612 + | fn from(value: First) -> Self {
|
4613 + | value.into_inner()
|
4614 + | }
|
4615 + | }
|
4616 + | #[cfg(test)]
|
4617 + | mod test_first {
|
4618 + | #[test]
|
4619 + | fn regex_compiles() {
|
4620 + | crate::model::pattern_union_override::First::compile_regex();
|
4621 + | }
|
4622 + | }
|
4623 + | #[allow(missing_docs)] // documentation missing in model
|
4624 + | ///
|
4625 + | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
4873 4626 | /// [constraint traits]. Use [`Second::try_from`] to construct values of this type.
|
4874 4627 | ///
|
4875 4628 | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
4876 4629 | ///
|
4877 4630 | #[derive(
|
4878 4631 | ::std::clone::Clone,
|
4879 4632 | ::std::cmp::Eq,
|
4880 4633 | ::std::cmp::PartialEq,
|
4881 4634 | ::std::fmt::Debug,
|
4882 4635 | ::std::hash::Hash,
|
4961 4714 | value.into_inner()
|
4962 4715 | }
|
4963 4716 | }
|
4964 4717 | #[cfg(test)]
|
4965 4718 | mod test_second {
|
4966 4719 | #[test]
|
4967 4720 | fn regex_compiles() {
|
4968 4721 | crate::model::pattern_union_override::Second::compile_regex();
|
4969 4722 | }
|
4970 4723 | }
|
4971 - | #[allow(missing_docs)] // documentation missing in model
|
4972 - | ///
|
4973 - | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
4974 - | /// [constraint traits]. Use [`First::try_from`] to construct values of this type.
|
4975 - | ///
|
4976 - | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
4977 - | ///
|
4978 - | #[derive(
|
4979 - | ::std::clone::Clone,
|
4980 - | ::std::cmp::Eq,
|
4981 - | ::std::cmp::PartialEq,
|
4982 - | ::std::fmt::Debug,
|
4983 - | ::std::hash::Hash,
|
4984 - | )]
|
4985 - | pub struct First(pub(crate) ::std::string::String);
|
4986 - | impl First {
|
4987 - | /// Extracts a string slice containing the entire underlying `String`.
|
4988 - | pub fn as_str(&self) -> &str {
|
4989 - | &self.0
|
4724 + |
|
4725 + | /// See [`PatternUnionOverrideFirst`](crate::model::pattern_union_override::First).
|
4726 + | pub mod first {
|
4727 + |
|
4728 + | #[derive(Debug, PartialEq)]
|
4729 + | pub enum ConstraintViolation {
|
4730 + | /// Error when a string doesn't satisfy its `@pattern`.
|
4731 + | /// Contains the String that failed the pattern.
|
4732 + | Pattern(String),
|
4990 4733 | }
|
4991 4734 |
|
4992 - | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
4993 - | pub fn inner(&self) -> &::std::string::String {
|
4994 - | &self.0
|
4735 + | impl ::std::fmt::Display for ConstraintViolation {
|
4736 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4737 + | let message = match self {
|
4738 + | Self::Pattern(_) => {
|
4739 + | format!(
|
4740 + | r#"Value provided for `aws.protocoltests.restjson.validation#PatternUnionOverrideFirst` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
4741 + | r#"^[g-m]+$"#
|
4742 + | )
|
4743 + | }
|
4744 + | };
|
4745 + | write!(f, "{message}")
|
4746 + | }
|
4995 4747 | }
|
4996 4748 |
|
4997 - | /// Consumes the value, returning the underlying [`::std::string::String`].
|
4998 - | pub fn into_inner(self) -> ::std::string::String {
|
4999 - | self.0
|
4749 + | impl ::std::error::Error for ConstraintViolation {}
|
4750 + | impl ConstraintViolation {
|
4751 + | pub(crate) fn as_validation_exception_field(
|
4752 + | self,
|
4753 + | path: ::std::string::String,
|
4754 + | ) -> crate::model::ValidationExceptionField {
|
4755 + | match self {
|
4756 + | #[allow(unused_variables)]
|
4757 + | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
4758 + | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^[g-m]+$"#),
|
4759 + | path
|
4760 + | },
|
5000 4761 | }
|
5001 4762 | }
|
5002 - | impl First {
|
5003 - | fn check_pattern(
|
5004 - | string: ::std::string::String,
|
5005 - | ) -> ::std::result::Result<
|
5006 - | ::std::string::String,
|
5007 - | crate::model::pattern_union_override::first::ConstraintViolation,
|
5008 - | > {
|
5009 - | let regex = Self::compile_regex();
|
4763 + | }
|
4764 + | }
|
4765 + | /// See [`PatternUnionOverrideSecond`](crate::model::pattern_union_override::Second).
|
4766 + | pub mod second {
|
5010 4767 |
|
5011 - | if regex.is_match(&string) {
|
5012 - | Ok(string)
|
5013 - | } else {
|
5014 - | Err(
|
5015 - | crate::model::pattern_union_override::first::ConstraintViolation::Pattern(
|
5016 - | string,
|
5017 - | ),
|
4768 + | #[derive(Debug, PartialEq)]
|
4769 + | pub enum ConstraintViolation {
|
4770 + | /// Error when a string doesn't satisfy its `@pattern`.
|
4771 + | /// Contains the String that failed the pattern.
|
4772 + | Pattern(String),
|
4773 + | }
|
4774 + |
|
4775 + | impl ::std::fmt::Display for ConstraintViolation {
|
4776 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4777 + | let message = match self {
|
4778 + | Self::Pattern(_) => {
|
4779 + | format!(
|
4780 + | r#"Value provided for `aws.protocoltests.restjson.validation#PatternUnionOverrideSecond` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
4781 + | r#"^[g-m]+$"#
|
5018 4782 | )
|
5019 4783 | }
|
4784 + | };
|
4785 + | write!(f, "{message}")
|
4786 + | }
|
5020 4787 | }
|
5021 4788 |
|
5022 - | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
5023 - | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
5024 - | pub fn compile_regex() -> &'static ::regex::Regex {
|
5025 - | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
5026 - | ::regex::Regex::new(r#"^[g-m]+$"#).expect(r#"The regular expression ^[g-m]+$ is not supported by the `regex` crate; feel free to file an issue under https://github.com/smithy-lang/smithy-rs/issues for support"#)
|
5027 - | });
|
4789 + | impl ::std::error::Error for ConstraintViolation {}
|
4790 + | impl ConstraintViolation {
|
4791 + | pub(crate) fn as_validation_exception_field(
|
4792 + | self,
|
4793 + | path: ::std::string::String,
|
4794 + | ) -> crate::model::ValidationExceptionField {
|
4795 + | match self {
|
4796 + | #[allow(unused_variables)]
|
4797 + | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
4798 + | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^[g-m]+$"#),
|
4799 + | path
|
4800 + | },
|
4801 + | }
|
4802 + | }
|
4803 + | }
|
4804 + | }
|
4805 + | }
|
4806 + | /// See [`RangeByte`](crate::model::RangeByte).
|
4807 + | pub mod range_byte {
|
5028 4808 |
|
5029 - | ®EX
|
4809 + | #[derive(Debug, PartialEq)]
|
4810 + | pub enum ConstraintViolation {
|
4811 + | Range(i8),
|
4812 + | }
|
4813 + |
|
4814 + | impl ::std::fmt::Display for ConstraintViolation {
|
4815 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4816 + | write!(f, "Value for `aws.protocoltests.restjson.validation#RangeByte`failed to satisfy constraint: Member must be between 2 and 8, inclusive")
|
5030 4817 | }
|
5031 4818 | }
|
5032 - | impl ::std::convert::TryFrom<::std::string::String> for First {
|
5033 - | type Error = crate::model::pattern_union_override::first::ConstraintViolation;
|
5034 4819 |
|
5035 - | /// Constructs a `First` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
5036 - | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
5037 - | let value = Self::check_pattern(value)?;
|
4820 + | impl ::std::error::Error for ConstraintViolation {}
|
4821 + | impl ConstraintViolation {
|
4822 + | pub(crate) fn as_validation_exception_field(
|
4823 + | self,
|
4824 + | path: ::std::string::String,
|
4825 + | ) -> crate::model::ValidationExceptionField {
|
4826 + | match self {
|
4827 + | Self::Range(_) => crate::model::ValidationExceptionField {
|
4828 + | message: format!("Value at '{}' failed to satisfy constraint: Member must be between 2 and 8, inclusive", &path),
|
4829 + | path,
|
4830 + | },
|
4831 + | }
|
4832 + | }
|
4833 + | }
|
4834 + | }
|
4835 + | /// See [`MinByte`](crate::model::MinByte).
|
4836 + | pub mod min_byte {
|
5038 4837 |
|
5039 - | Ok(Self(value))
|
4838 + | #[derive(Debug, PartialEq)]
|
4839 + | pub enum ConstraintViolation {
|
4840 + | Range(i8),
|
5040 4841 | }
|
4842 + |
|
4843 + | impl ::std::fmt::Display for ConstraintViolation {
|
4844 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4845 + | write!(f, "Value for `aws.protocoltests.restjson.validation#MinByte`failed to satisfy constraint: Member must be greater than or equal to 2")
|
5041 4846 | }
|
5042 - | impl crate::constrained::Constrained for First {
|
5043 - | type Unconstrained = ::std::string::String;
|
5044 4847 | }
|
5045 4848 |
|
5046 - | impl ::std::convert::From<::std::string::String>
|
5047 - | for crate::constrained::MaybeConstrained<crate::model::pattern_union_override::First>
|
5048 - | {
|
5049 - | fn from(value: ::std::string::String) -> Self {
|
5050 - | Self::Unconstrained(value)
|
4849 + | impl ::std::error::Error for ConstraintViolation {}
|
4850 + | impl ConstraintViolation {
|
4851 + | pub(crate) fn as_validation_exception_field(
|
4852 + | self,
|
4853 + | path: ::std::string::String,
|
4854 + | ) -> crate::model::ValidationExceptionField {
|
4855 + | match self {
|
4856 + | Self::Range(_) => crate::model::ValidationExceptionField {
|
4857 + | message: format!("Value at '{}' failed to satisfy constraint: Member must be greater than or equal to 2", &path),
|
4858 + | path,
|
4859 + | },
|
4860 + | }
|
4861 + | }
|
4862 + | }
|
4863 + | }
|
4864 + | /// See [`MaxByte`](crate::model::MaxByte).
|
4865 + | pub mod max_byte {
|
4866 + |
|
4867 + | #[derive(Debug, PartialEq)]
|
4868 + | pub enum ConstraintViolation {
|
4869 + | Range(i8),
|
4870 + | }
|
4871 + |
|
4872 + | impl ::std::fmt::Display for ConstraintViolation {
|
4873 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4874 + | write!(f, "Value for `aws.protocoltests.restjson.validation#MaxByte`failed to satisfy constraint: Member must be less than or equal to 8")
|
4875 + | }
|
4876 + | }
|
4877 + |
|
4878 + | impl ::std::error::Error for ConstraintViolation {}
|
4879 + | impl ConstraintViolation {
|
4880 + | pub(crate) fn as_validation_exception_field(
|
4881 + | self,
|
4882 + | path: ::std::string::String,
|
4883 + | ) -> crate::model::ValidationExceptionField {
|
4884 + | match self {
|
4885 + | Self::Range(_) => crate::model::ValidationExceptionField {
|
4886 + | message: format!("Value at '{}' failed to satisfy constraint: Member must be less than or equal to 8", &path),
|
4887 + | path,
|
4888 + | },
|
4889 + | }
|
4890 + | }
|
4891 + | }
|
4892 + | }
|
4893 + | /// See [`RangeShort`](crate::model::RangeShort).
|
4894 + | pub mod range_short {
|
4895 + |
|
4896 + | #[derive(Debug, PartialEq)]
|
4897 + | pub enum ConstraintViolation {
|
4898 + | Range(i16),
|
4899 + | }
|
4900 + |
|
4901 + | impl ::std::fmt::Display for ConstraintViolation {
|
4902 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4903 + | write!(f, "Value for `aws.protocoltests.restjson.validation#RangeShort`failed to satisfy constraint: Member must be between 2 and 8, inclusive")
|
4904 + | }
|
4905 + | }
|
4906 + |
|
4907 + | impl ::std::error::Error for ConstraintViolation {}
|
4908 + | impl ConstraintViolation {
|
4909 + | pub(crate) fn as_validation_exception_field(
|
4910 + | self,
|
4911 + | path: ::std::string::String,
|
4912 + | ) -> crate::model::ValidationExceptionField {
|
4913 + | match self {
|
4914 + | Self::Range(_) => crate::model::ValidationExceptionField {
|
4915 + | message: format!("Value at '{}' failed to satisfy constraint: Member must be between 2 and 8, inclusive", &path),
|
4916 + | path,
|
4917 + | },
|
4918 + | }
|
5051 4919 | }
|
5052 4920 | }
|
4921 + | }
|
4922 + | /// See [`MinShort`](crate::model::MinShort).
|
4923 + | pub mod min_short {
|
4924 + |
|
4925 + | #[derive(Debug, PartialEq)]
|
4926 + | pub enum ConstraintViolation {
|
4927 + | Range(i16),
|
4928 + | }
|
5053 4929 |
|
5054 - | impl ::std::fmt::Display for First {
|
4930 + | impl ::std::fmt::Display for ConstraintViolation {
|
5055 4931 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5056 - | self.0.fmt(f)
|
4932 + | write!(f, "Value for `aws.protocoltests.restjson.validation#MinShort`failed to satisfy constraint: Member must be greater than or equal to 2")
|
5057 4933 | }
|
5058 4934 | }
|
5059 4935 |
|
5060 - | impl ::std::convert::From<First> for ::std::string::String {
|
5061 - | fn from(value: First) -> Self {
|
5062 - | value.into_inner()
|
5063 - | }
|
4936 + | impl ::std::error::Error for ConstraintViolation {}
|
4937 + | impl ConstraintViolation {
|
4938 + | pub(crate) fn as_validation_exception_field(
|
4939 + | self,
|
4940 + | path: ::std::string::String,
|
4941 + | ) -> crate::model::ValidationExceptionField {
|
4942 + | match self {
|
4943 + | Self::Range(_) => crate::model::ValidationExceptionField {
|
4944 + | message: format!("Value at '{}' failed to satisfy constraint: Member must be greater than or equal to 2", &path),
|
4945 + | path,
|
4946 + | },
|
5064 4947 | }
|
5065 - | #[cfg(test)]
|
5066 - | mod test_first {
|
5067 - | #[test]
|
5068 - | fn regex_compiles() {
|
5069 - | crate::model::pattern_union_override::First::compile_regex();
|
5070 4948 | }
|
5071 4949 | }
|
5072 - |
|
5073 - | /// See [`PatternUnionOverrideSecond`](crate::model::pattern_union_override::Second).
|
5074 - | pub mod second {
|
4950 + | }
|
4951 + | /// See [`MaxShort`](crate::model::MaxShort).
|
4952 + | pub mod max_short {
|
5075 4953 |
|
5076 4954 | #[derive(Debug, PartialEq)]
|
5077 4955 | pub enum ConstraintViolation {
|
5078 - | /// Error when a string doesn't satisfy its `@pattern`.
|
5079 - | /// Contains the String that failed the pattern.
|
5080 - | Pattern(String),
|
4956 + | Range(i16),
|
5081 4957 | }
|
5082 4958 |
|
5083 4959 | impl ::std::fmt::Display for ConstraintViolation {
|
5084 4960 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5085 - | let message = match self {
|
5086 - | Self::Pattern(_) => {
|
5087 - | format!(
|
5088 - | r#"Value provided for `aws.protocoltests.restjson.validation#PatternUnionOverrideSecond` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
5089 - | r#"^[g-m]+$"#
|
5090 - | )
|
5091 - | }
|
5092 - | };
|
5093 - | write!(f, "{message}")
|
4961 + | write!(f, "Value for `aws.protocoltests.restjson.validation#MaxShort`failed to satisfy constraint: Member must be less than or equal to 8")
|
5094 4962 | }
|
5095 4963 | }
|
5096 4964 |
|
5097 4965 | impl ::std::error::Error for ConstraintViolation {}
|
5098 4966 | impl ConstraintViolation {
|
5099 4967 | pub(crate) fn as_validation_exception_field(
|
5100 4968 | self,
|
5101 4969 | path: ::std::string::String,
|
5102 4970 | ) -> crate::model::ValidationExceptionField {
|
5103 4971 | match self {
|
5104 - | #[allow(unused_variables)]
|
5105 - | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
5106 - | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^[g-m]+$"#),
|
5107 - | path
|
4972 + | Self::Range(_) => crate::model::ValidationExceptionField {
|
4973 + | message: format!("Value at '{}' failed to satisfy constraint: Member must be less than or equal to 8", &path),
|
4974 + | path,
|
5108 4975 | },
|
5109 4976 | }
|
5110 4977 | }
|
5111 4978 | }
|
5112 - | }
|
5113 - | /// See [`PatternUnionOverrideFirst`](crate::model::pattern_union_override::First).
|
5114 - | pub mod first {
|
4979 + | }
|
4980 + | /// See [`RangeInteger`](crate::model::RangeInteger).
|
4981 + | pub mod range_integer {
|
5115 4982 |
|
5116 4983 | #[derive(Debug, PartialEq)]
|
5117 4984 | pub enum ConstraintViolation {
|
5118 - | /// Error when a string doesn't satisfy its `@pattern`.
|
5119 - | /// Contains the String that failed the pattern.
|
5120 - | Pattern(String),
|
4985 + | Range(i32),
|
5121 4986 | }
|
5122 4987 |
|
5123 4988 | impl ::std::fmt::Display for ConstraintViolation {
|
5124 4989 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5125 - | let message = match self {
|
5126 - | Self::Pattern(_) => {
|
5127 - | format!(
|
5128 - | r#"Value provided for `aws.protocoltests.restjson.validation#PatternUnionOverrideFirst` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
5129 - | r#"^[g-m]+$"#
|
5130 - | )
|
5131 - | }
|
5132 - | };
|
5133 - | write!(f, "{message}")
|
4990 + | write!(f, "Value for `aws.protocoltests.restjson.validation#RangeInteger`failed to satisfy constraint: Member must be between 2 and 8, inclusive")
|
5134 4991 | }
|
5135 4992 | }
|
5136 4993 |
|
5137 4994 | impl ::std::error::Error for ConstraintViolation {}
|
5138 4995 | impl ConstraintViolation {
|
5139 4996 | pub(crate) fn as_validation_exception_field(
|
5140 4997 | self,
|
5141 4998 | path: ::std::string::String,
|
5142 4999 | ) -> crate::model::ValidationExceptionField {
|
5143 5000 | match self {
|
5144 - | #[allow(unused_variables)]
|
5145 - | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
5146 - | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^[g-m]+$"#),
|
5147 - | path
|
5001 + | Self::Range(_) => crate::model::ValidationExceptionField {
|
5002 + | message: format!("Value at '{}' failed to satisfy constraint: Member must be between 2 and 8, inclusive", &path),
|
5003 + | path,
|
5148 5004 | },
|
5149 5005 | }
|
5150 5006 | }
|
5151 5007 | }
|
5152 - | }
|
5153 5008 | }
|
5154 - | pub mod pattern_map_override {
|
5009 + | /// See [`MinInteger`](crate::model::MinInteger).
|
5010 + | pub mod min_integer {
|
5155 5011 |
|
5156 - | #[allow(clippy::enum_variant_names)]
|
5157 5012 | #[derive(Debug, PartialEq)]
|
5158 5013 | pub enum ConstraintViolation {
|
5159 - | #[doc(hidden)]
|
5160 - | Key(crate::model::pattern_map_override::key::ConstraintViolation),
|
5161 - | #[doc(hidden)]
|
5162 - | Value(
|
5163 - | crate::model::pattern_map_override::Key,
|
5164 - | crate::model::pattern_map_override::value::ConstraintViolation,
|
5165 - | ),
|
5014 + | Range(i32),
|
5166 5015 | }
|
5167 5016 |
|
5168 5017 | impl ::std::fmt::Display for ConstraintViolation {
|
5169 5018 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5170 - | match self {
|
5171 - | Self::Key(key_constraint_violation) => write!(f, "{}", key_constraint_violation),
|
5172 - | Self::Value(_, value_constraint_violation) => {
|
5173 - | write!(f, "{}", value_constraint_violation)
|
5174 - | }
|
5175 - | }
|
5019 + | write!(f, "Value for `aws.protocoltests.restjson.validation#MinInteger`failed to satisfy constraint: Member must be greater than or equal to 2")
|
5176 5020 | }
|
5177 5021 | }
|
5178 5022 |
|
5179 5023 | impl ::std::error::Error for ConstraintViolation {}
|
5180 5024 | impl ConstraintViolation {
|
5181 5025 | pub(crate) fn as_validation_exception_field(
|
5182 5026 | self,
|
5183 5027 | path: ::std::string::String,
|
5184 5028 | ) -> crate::model::ValidationExceptionField {
|
5185 5029 | match self {
|
5186 - | Self::Key(key_constraint_violation) => {
|
5187 - | key_constraint_violation.as_validation_exception_field(path)
|
5188 - | }
|
5189 - | Self::Value(key, value_constraint_violation) => value_constraint_violation
|
5190 - | .as_validation_exception_field(path + "/" + key.as_str()),
|
5191 - | }
|
5030 + | Self::Range(_) => crate::model::ValidationExceptionField {
|
5031 + | message: format!("Value at '{}' failed to satisfy constraint: Member must be greater than or equal to 2", &path),
|
5032 + | path,
|
5033 + | },
|
5192 5034 | }
|
5193 5035 | }
|
5194 - | #[allow(missing_docs)] // documentation missing in model
|
5195 - | ///
|
5196 - | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
5197 - | /// [constraint traits]. Use [`Value::try_from`] to construct values of this type.
|
5198 - | ///
|
5199 - | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
5200 - | ///
|
5201 - | #[derive(
|
5202 - | ::std::clone::Clone,
|
5203 - | ::std::cmp::Eq,
|
5204 - | ::std::cmp::PartialEq,
|
5205 - | ::std::fmt::Debug,
|
5206 - | ::std::hash::Hash,
|
5207 - | )]
|
5208 - | pub struct Value(pub(crate) ::std::string::String);
|
5209 - | impl Value {
|
5210 - | /// Extracts a string slice containing the entire underlying `String`.
|
5211 - | pub fn as_str(&self) -> &str {
|
5212 - | &self.0
|
5213 5036 | }
|
5037 + | }
|
5038 + | /// See [`MaxInteger`](crate::model::MaxInteger).
|
5039 + | pub mod max_integer {
|
5214 5040 |
|
5215 - | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
5216 - | pub fn inner(&self) -> &::std::string::String {
|
5217 - | &self.0
|
5041 + | #[derive(Debug, PartialEq)]
|
5042 + | pub enum ConstraintViolation {
|
5043 + | Range(i32),
|
5218 5044 | }
|
5219 5045 |
|
5220 - | /// Consumes the value, returning the underlying [`::std::string::String`].
|
5221 - | pub fn into_inner(self) -> ::std::string::String {
|
5222 - | self.0
|
5046 + | impl ::std::fmt::Display for ConstraintViolation {
|
5047 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5048 + | write!(f, "Value for `aws.protocoltests.restjson.validation#MaxInteger`failed to satisfy constraint: Member must be less than or equal to 8")
|
5223 5049 | }
|
5224 5050 | }
|
5225 - | impl Value {
|
5226 - | fn check_pattern(
|
5227 - | string: ::std::string::String,
|
5228 - | ) -> ::std::result::Result<
|
5229 - | ::std::string::String,
|
5230 - | crate::model::pattern_map_override::value::ConstraintViolation,
|
5231 - | > {
|
5232 - | let regex = Self::compile_regex();
|
5233 5051 |
|
5234 - | if regex.is_match(&string) {
|
5235 - | Ok(string)
|
5236 - | } else {
|
5237 - | Err(crate::model::pattern_map_override::value::ConstraintViolation::Pattern(string))
|
5052 + | impl ::std::error::Error for ConstraintViolation {}
|
5053 + | impl ConstraintViolation {
|
5054 + | pub(crate) fn as_validation_exception_field(
|
5055 + | self,
|
5056 + | path: ::std::string::String,
|
5057 + | ) -> crate::model::ValidationExceptionField {
|
5058 + | match self {
|
5059 + | Self::Range(_) => crate::model::ValidationExceptionField {
|
5060 + | message: format!("Value at '{}' failed to satisfy constraint: Member must be less than or equal to 8", &path),
|
5061 + | path,
|
5062 + | },
|
5063 + | }
|
5238 5064 | }
|
5239 5065 | }
|
5066 + | }
|
5067 + | /// See [`RangeLong`](crate::model::RangeLong).
|
5068 + | pub mod range_long {
|
5240 5069 |
|
5241 - | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
5242 - | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
5243 - | pub fn compile_regex() -> &'static ::regex::Regex {
|
5244 - | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
5245 - | ::regex::Regex::new(r#"^[g-m]+$"#).expect(r#"The regular expression ^[g-m]+$ is not supported by the `regex` crate; feel free to file an issue under https://github.com/smithy-lang/smithy-rs/issues for support"#)
|
5246 - | });
|
5070 + | #[derive(Debug, PartialEq)]
|
5071 + | pub enum ConstraintViolation {
|
5072 + | Range(i64),
|
5073 + | }
|
5247 5074 |
|
5248 - | ®EX
|
5075 + | impl ::std::fmt::Display for ConstraintViolation {
|
5076 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5077 + | write!(f, "Value for `aws.protocoltests.restjson.validation#RangeLong`failed to satisfy constraint: Member must be between 2 and 8, inclusive")
|
5249 5078 | }
|
5250 5079 | }
|
5251 - | impl ::std::convert::TryFrom<::std::string::String> for Value {
|
5252 - | type Error = crate::model::pattern_map_override::value::ConstraintViolation;
|
5253 - |
|
5254 - | /// Constructs a `Value` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
5255 - | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
5256 - | let value = Self::check_pattern(value)?;
|
5257 5080 |
|
5258 - | Ok(Self(value))
|
5081 + | impl ::std::error::Error for ConstraintViolation {}
|
5082 + | impl ConstraintViolation {
|
5083 + | pub(crate) fn as_validation_exception_field(
|
5084 + | self,
|
5085 + | path: ::std::string::String,
|
5086 + | ) -> crate::model::ValidationExceptionField {
|
5087 + | match self {
|
5088 + | Self::Range(_) => crate::model::ValidationExceptionField {
|
5089 + | message: format!("Value at '{}' failed to satisfy constraint: Member must be between 2 and 8, inclusive", &path),
|
5090 + | path,
|
5091 + | },
|
5259 5092 | }
|
5260 5093 | }
|
5261 - | impl crate::constrained::Constrained for Value {
|
5262 - | type Unconstrained = ::std::string::String;
|
5263 5094 | }
|
5095 + | }
|
5096 + | /// See [`MinLong`](crate::model::MinLong).
|
5097 + | pub mod min_long {
|
5264 5098 |
|
5265 - | impl ::std::convert::From<::std::string::String>
|
5266 - | for crate::constrained::MaybeConstrained<crate::model::pattern_map_override::Value>
|
5267 - | {
|
5268 - | fn from(value: ::std::string::String) -> Self {
|
5269 - | Self::Unconstrained(value)
|
5270 - | }
|
5099 + | #[derive(Debug, PartialEq)]
|
5100 + | pub enum ConstraintViolation {
|
5101 + | Range(i64),
|
5271 5102 | }
|
5272 5103 |
|
5273 - | impl ::std::fmt::Display for Value {
|
5104 + | impl ::std::fmt::Display for ConstraintViolation {
|
5274 5105 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5275 - | self.0.fmt(f)
|
5106 + | write!(f, "Value for `aws.protocoltests.restjson.validation#MinLong`failed to satisfy constraint: Member must be greater than or equal to 2")
|
5276 5107 | }
|
5277 5108 | }
|
5278 5109 |
|
5279 - | impl ::std::convert::From<Value> for ::std::string::String {
|
5280 - | fn from(value: Value) -> Self {
|
5281 - | value.into_inner()
|
5282 - | }
|
5283 - | }
|
5284 - | #[cfg(test)]
|
5285 - | mod test_value {
|
5286 - | #[test]
|
5287 - | fn regex_compiles() {
|
5288 - | crate::model::pattern_map_override::Value::compile_regex();
|
5289 - | }
|
5290 - | }
|
5291 - | #[allow(missing_docs)] // documentation missing in model
|
5292 - | ///
|
5293 - | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
5294 - | /// [constraint traits]. Use [`Key::try_from`] to construct values of this type.
|
5295 - | ///
|
5296 - | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
5297 - | ///
|
5298 - | #[derive(
|
5299 - | ::std::clone::Clone,
|
5300 - | ::std::cmp::Eq,
|
5301 - | ::std::cmp::PartialEq,
|
5302 - | ::std::fmt::Debug,
|
5303 - | ::std::hash::Hash,
|
5304 - | )]
|
5305 - | pub struct Key(pub(crate) ::std::string::String);
|
5306 - | impl Key {
|
5307 - | /// Extracts a string slice containing the entire underlying `String`.
|
5308 - | pub fn as_str(&self) -> &str {
|
5309 - | &self.0
|
5110 + | impl ::std::error::Error for ConstraintViolation {}
|
5111 + | impl ConstraintViolation {
|
5112 + | pub(crate) fn as_validation_exception_field(
|
5113 + | self,
|
5114 + | path: ::std::string::String,
|
5115 + | ) -> crate::model::ValidationExceptionField {
|
5116 + | match self {
|
5117 + | Self::Range(_) => crate::model::ValidationExceptionField {
|
5118 + | message: format!("Value at '{}' failed to satisfy constraint: Member must be greater than or equal to 2", &path),
|
5119 + | path,
|
5120 + | },
|
5121 + | }
|
5310 5122 | }
|
5123 + | }
|
5124 + | }
|
5125 + | /// See [`MaxLong`](crate::model::MaxLong).
|
5126 + | pub mod max_long {
|
5311 5127 |
|
5312 - | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
5313 - | pub fn inner(&self) -> &::std::string::String {
|
5314 - | &self.0
|
5128 + | #[derive(Debug, PartialEq)]
|
5129 + | pub enum ConstraintViolation {
|
5130 + | Range(i64),
|
5315 5131 | }
|
5316 5132 |
|
5317 - | /// Consumes the value, returning the underlying [`::std::string::String`].
|
5318 - | pub fn into_inner(self) -> ::std::string::String {
|
5319 - | self.0
|
5133 + | impl ::std::fmt::Display for ConstraintViolation {
|
5134 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5135 + | write!(f, "Value for `aws.protocoltests.restjson.validation#MaxLong`failed to satisfy constraint: Member must be less than or equal to 8")
|
5320 5136 | }
|
5321 5137 | }
|
5322 - | impl Key {
|
5323 - | fn check_pattern(
|
5324 - | string: ::std::string::String,
|
5325 - | ) -> ::std::result::Result<
|
5326 - | ::std::string::String,
|
5327 - | crate::model::pattern_map_override::key::ConstraintViolation,
|
5328 - | > {
|
5329 - | let regex = Self::compile_regex();
|
5330 5138 |
|
5331 - | if regex.is_match(&string) {
|
5332 - | Ok(string)
|
5333 - | } else {
|
5334 - | Err(crate::model::pattern_map_override::key::ConstraintViolation::Pattern(string))
|
5139 + | impl ::std::error::Error for ConstraintViolation {}
|
5140 + | impl ConstraintViolation {
|
5141 + | pub(crate) fn as_validation_exception_field(
|
5142 + | self,
|
5143 + | path: ::std::string::String,
|
5144 + | ) -> crate::model::ValidationExceptionField {
|
5145 + | match self {
|
5146 + | Self::Range(_) => crate::model::ValidationExceptionField {
|
5147 + | message: format!("Value at '{}' failed to satisfy constraint: Member must be less than or equal to 8", &path),
|
5148 + | path,
|
5149 + | },
|
5150 + | }
|
5335 5151 | }
|
5336 5152 | }
|
5153 + | }
|
5154 + | /// See [`BlobSet`](crate::model::BlobSet).
|
5155 + | pub mod blob_set {
|
5337 5156 |
|
5338 - | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
5339 - | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
5340 - | pub fn compile_regex() -> &'static ::regex::Regex {
|
5341 - | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
5342 - | ::regex::Regex::new(r#"^[g-m]+$"#).expect(r#"The regular expression ^[g-m]+$ is not supported by the `regex` crate; feel free to file an issue under https://github.com/smithy-lang/smithy-rs/issues for support"#)
|
5343 - | });
|
5157 + | #[allow(clippy::enum_variant_names)]
|
5158 + | #[derive(Debug, PartialEq)]
|
5159 + | pub enum ConstraintViolation {
|
5160 + | /// Constraint violation error when the list does not contain unique items
|
5161 + | UniqueItems {
|
5162 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5163 + | /// at least two elements.
|
5164 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5165 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5166 + | /// Nothing is guaranteed about the order of the indices.
|
5167 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5168 + | /// The original vector, that contains duplicate items.
|
5169 + | original: ::std::vec::Vec<::aws_smithy_types::Blob>,
|
5170 + | },
|
5171 + | }
|
5344 5172 |
|
5345 - | ®EX
|
5173 + | impl ::std::fmt::Display for ConstraintViolation {
|
5174 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5175 + | let message = match self {
|
5176 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5177 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#BlobSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5178 + | };
|
5179 + | write!(f, "{message}")
|
5346 5180 | }
|
5347 5181 | }
|
5348 - | impl ::std::convert::TryFrom<::std::string::String> for Key {
|
5349 - | type Error = crate::model::pattern_map_override::key::ConstraintViolation;
|
5350 5182 |
|
5351 - | /// Constructs a `Key` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
5352 - | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
5353 - | let value = Self::check_pattern(value)?;
|
5354 - |
|
5355 - | Ok(Self(value))
|
5183 + | impl ::std::error::Error for ConstraintViolation {}
|
5184 + | impl ConstraintViolation {
|
5185 + | pub(crate) fn as_validation_exception_field(
|
5186 + | self,
|
5187 + | path: ::std::string::String,
|
5188 + | ) -> crate::model::ValidationExceptionField {
|
5189 + | match self {
|
5190 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5191 + | crate::model::ValidationExceptionField {
|
5192 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5193 + | path,
|
5194 + | },
|
5356 5195 | }
|
5357 5196 | }
|
5358 - | impl crate::constrained::Constrained for Key {
|
5359 - | type Unconstrained = ::std::string::String;
|
5360 5197 | }
|
5198 + | }
|
5199 + | /// See [`BooleanSet`](crate::model::BooleanSet).
|
5200 + | pub mod boolean_set {
|
5361 5201 |
|
5362 - | impl ::std::convert::From<::std::string::String>
|
5363 - | for crate::constrained::MaybeConstrained<crate::model::pattern_map_override::Key>
|
5364 - | {
|
5365 - | fn from(value: ::std::string::String) -> Self {
|
5366 - | Self::Unconstrained(value)
|
5367 - | }
|
5202 + | #[allow(clippy::enum_variant_names)]
|
5203 + | #[derive(Debug, PartialEq)]
|
5204 + | pub enum ConstraintViolation {
|
5205 + | /// Constraint violation error when the list does not contain unique items
|
5206 + | UniqueItems {
|
5207 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5208 + | /// at least two elements.
|
5209 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5210 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5211 + | /// Nothing is guaranteed about the order of the indices.
|
5212 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5213 + | /// The original vector, that contains duplicate items.
|
5214 + | original: ::std::vec::Vec<bool>,
|
5215 + | },
|
5368 5216 | }
|
5369 5217 |
|
5370 - | impl ::std::fmt::Display for Key {
|
5218 + | impl ::std::fmt::Display for ConstraintViolation {
|
5371 5219 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5372 - | self.0.fmt(f)
|
5220 + | let message = match self {
|
5221 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5222 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#BooleanSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5223 + | };
|
5224 + | write!(f, "{message}")
|
5373 5225 | }
|
5374 5226 | }
|
5375 5227 |
|
5376 - | impl ::std::convert::From<Key> for ::std::string::String {
|
5377 - | fn from(value: Key) -> Self {
|
5378 - | value.into_inner()
|
5379 - | }
|
5228 + | impl ::std::error::Error for ConstraintViolation {}
|
5229 + | impl ConstraintViolation {
|
5230 + | pub(crate) fn as_validation_exception_field(
|
5231 + | self,
|
5232 + | path: ::std::string::String,
|
5233 + | ) -> crate::model::ValidationExceptionField {
|
5234 + | match self {
|
5235 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5236 + | crate::model::ValidationExceptionField {
|
5237 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5238 + | path,
|
5239 + | },
|
5380 5240 | }
|
5381 - | #[cfg(test)]
|
5382 - | mod test_key {
|
5383 - | #[test]
|
5384 - | fn regex_compiles() {
|
5385 - | crate::model::pattern_map_override::Key::compile_regex();
|
5386 5241 | }
|
5387 5242 | }
|
5243 + | }
|
5244 + | /// See [`StringSet`](crate::model::StringSet).
|
5245 + | pub mod string_set {
|
5388 5246 |
|
5389 - | /// See [`PatternMapOverrideValue`](crate::model::pattern_map_override::Value).
|
5390 - | pub mod value {
|
5391 - |
|
5247 + | #[allow(clippy::enum_variant_names)]
|
5392 5248 | #[derive(Debug, PartialEq)]
|
5393 5249 | pub enum ConstraintViolation {
|
5394 - | /// Error when a string doesn't satisfy its `@pattern`.
|
5395 - | /// Contains the String that failed the pattern.
|
5396 - | Pattern(String),
|
5250 + | /// Constraint violation error when the list does not contain unique items
|
5251 + | UniqueItems {
|
5252 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5253 + | /// at least two elements.
|
5254 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5255 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5256 + | /// Nothing is guaranteed about the order of the indices.
|
5257 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5258 + | /// The original vector, that contains duplicate items.
|
5259 + | original: ::std::vec::Vec<::std::string::String>,
|
5260 + | },
|
5397 5261 | }
|
5398 5262 |
|
5399 5263 | impl ::std::fmt::Display for ConstraintViolation {
|
5400 5264 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5401 5265 | let message = match self {
|
5402 - | Self::Pattern(_) => {
|
5403 - | format!(
|
5404 - | r#"Value provided for `aws.protocoltests.restjson.validation#PatternMapOverrideValue` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
5405 - | r#"^[g-m]+$"#
|
5406 - | )
|
5407 - | }
|
5266 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5267 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#StringSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5408 5268 | };
|
5409 5269 | write!(f, "{message}")
|
5410 5270 | }
|
5411 5271 | }
|
5412 5272 |
|
5413 5273 | impl ::std::error::Error for ConstraintViolation {}
|
5414 5274 | impl ConstraintViolation {
|
5415 5275 | pub(crate) fn as_validation_exception_field(
|
5416 5276 | self,
|
5417 5277 | path: ::std::string::String,
|
5418 5278 | ) -> crate::model::ValidationExceptionField {
|
5419 5279 | match self {
|
5420 - | #[allow(unused_variables)]
|
5421 - | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
5422 - | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^[g-m]+$"#),
|
5423 - | path
|
5280 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5281 + | crate::model::ValidationExceptionField {
|
5282 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5283 + | path,
|
5424 5284 | },
|
5425 5285 | }
|
5426 5286 | }
|
5427 5287 | }
|
5428 - | }
|
5429 - | /// See [`PatternMapOverrideKey`](crate::model::pattern_map_override::Key).
|
5430 - | pub mod key {
|
5288 + | }
|
5289 + | /// See [`ByteSet`](crate::model::ByteSet).
|
5290 + | pub mod byte_set {
|
5431 5291 |
|
5292 + | #[allow(clippy::enum_variant_names)]
|
5432 5293 | #[derive(Debug, PartialEq)]
|
5433 5294 | pub enum ConstraintViolation {
|
5434 - | /// Error when a string doesn't satisfy its `@pattern`.
|
5435 - | /// Contains the String that failed the pattern.
|
5436 - | Pattern(String),
|
5295 + | /// Constraint violation error when the list does not contain unique items
|
5296 + | UniqueItems {
|
5297 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5298 + | /// at least two elements.
|
5299 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5300 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5301 + | /// Nothing is guaranteed about the order of the indices.
|
5302 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5303 + | /// The original vector, that contains duplicate items.
|
5304 + | original: ::std::vec::Vec<i8>,
|
5305 + | },
|
5437 5306 | }
|
5438 5307 |
|
5439 5308 | impl ::std::fmt::Display for ConstraintViolation {
|
5440 5309 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5441 5310 | let message = match self {
|
5442 - | Self::Pattern(_) => {
|
5443 - | format!(
|
5444 - | r#"Value provided for `aws.protocoltests.restjson.validation#PatternMapOverrideKey` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
5445 - | r#"^[g-m]+$"#
|
5446 - | )
|
5311 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5312 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#ByteSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5313 + | };
|
5314 + | write!(f, "{message}")
|
5315 + | }
|
5316 + | }
|
5317 + |
|
5318 + | impl ::std::error::Error for ConstraintViolation {}
|
5319 + | impl ConstraintViolation {
|
5320 + | pub(crate) fn as_validation_exception_field(
|
5321 + | self,
|
5322 + | path: ::std::string::String,
|
5323 + | ) -> crate::model::ValidationExceptionField {
|
5324 + | match self {
|
5325 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5326 + | crate::model::ValidationExceptionField {
|
5327 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5328 + | path,
|
5329 + | },
|
5330 + | }
|
5331 + | }
|
5332 + | }
|
5333 + | }
|
5334 + | /// See [`ShortSet`](crate::model::ShortSet).
|
5335 + | pub mod short_set {
|
5336 + |
|
5337 + | #[allow(clippy::enum_variant_names)]
|
5338 + | #[derive(Debug, PartialEq)]
|
5339 + | pub enum ConstraintViolation {
|
5340 + | /// Constraint violation error when the list does not contain unique items
|
5341 + | UniqueItems {
|
5342 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5343 + | /// at least two elements.
|
5344 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5345 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5346 + | /// Nothing is guaranteed about the order of the indices.
|
5347 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5348 + | /// The original vector, that contains duplicate items.
|
5349 + | original: ::std::vec::Vec<i16>,
|
5350 + | },
|
5447 5351 | }
|
5352 + |
|
5353 + | impl ::std::fmt::Display for ConstraintViolation {
|
5354 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5355 + | let message = match self {
|
5356 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5357 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#ShortSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5448 5358 | };
|
5449 5359 | write!(f, "{message}")
|
5450 5360 | }
|
5451 5361 | }
|
5452 5362 |
|
5453 5363 | impl ::std::error::Error for ConstraintViolation {}
|
5454 5364 | impl ConstraintViolation {
|
5455 5365 | pub(crate) fn as_validation_exception_field(
|
5456 5366 | self,
|
5457 5367 | path: ::std::string::String,
|
5458 5368 | ) -> crate::model::ValidationExceptionField {
|
5459 5369 | match self {
|
5460 - | #[allow(unused_variables)]
|
5461 - | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
5462 - | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^[g-m]+$"#),
|
5463 - | path
|
5370 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5371 + | crate::model::ValidationExceptionField {
|
5372 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5373 + | path,
|
5464 5374 | },
|
5465 5375 | }
|
5466 5376 | }
|
5467 5377 | }
|
5468 - | }
|
5469 5378 | }
|
5470 - | pub mod pattern_list_override {
|
5379 + | /// See [`IntegerSet`](crate::model::IntegerSet).
|
5380 + | pub mod integer_set {
|
5471 5381 |
|
5472 5382 | #[allow(clippy::enum_variant_names)]
|
5473 5383 | #[derive(Debug, PartialEq)]
|
5474 5384 | pub enum ConstraintViolation {
|
5475 - | /// Constraint violation error when an element doesn't satisfy its own constraints.
|
5476 - | /// The first component of the tuple is the index in the collection where the
|
5477 - | /// first constraint violation was found.
|
5478 - | #[doc(hidden)]
|
5479 - | Member(
|
5480 - | usize,
|
5481 - | crate::model::pattern_list_override::member::ConstraintViolation,
|
5482 - | ),
|
5385 + | /// Constraint violation error when the list does not contain unique items
|
5386 + | UniqueItems {
|
5387 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5388 + | /// at least two elements.
|
5389 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5390 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5391 + | /// Nothing is guaranteed about the order of the indices.
|
5392 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5393 + | /// The original vector, that contains duplicate items.
|
5394 + | original: ::std::vec::Vec<i32>,
|
5395 + | },
|
5483 5396 | }
|
5484 5397 |
|
5485 5398 | impl ::std::fmt::Display for ConstraintViolation {
|
5486 5399 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5487 5400 | let message = match self {
|
5488 - | Self::Member(index, failing_member) => format!(
|
5489 - | "Value at index {index} failed to satisfy constraint. {}",
|
5490 - | failing_member
|
5491 - | ),
|
5401 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5402 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#IntegerSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5492 5403 | };
|
5493 5404 | write!(f, "{message}")
|
5494 5405 | }
|
5495 5406 | }
|
5496 5407 |
|
5497 5408 | impl ::std::error::Error for ConstraintViolation {}
|
5498 5409 | impl ConstraintViolation {
|
5499 5410 | pub(crate) fn as_validation_exception_field(
|
5500 5411 | self,
|
5501 5412 | path: ::std::string::String,
|
5502 5413 | ) -> crate::model::ValidationExceptionField {
|
5503 5414 | match self {
|
5504 - | Self::Member(index, member_constraint_violation) => member_constraint_violation
|
5505 - | .as_validation_exception_field(path + "/" + &index.to_string()),
|
5506 - | }
|
5507 - | }
|
5508 - | }
|
5509 - | #[allow(missing_docs)] // documentation missing in model
|
5510 - | ///
|
5511 - | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
5512 - | /// [constraint traits]. Use [`Member::try_from`] to construct values of this type.
|
5513 - | ///
|
5514 - | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
5515 - | ///
|
5516 - | #[derive(
|
5517 - | ::std::clone::Clone,
|
5518 - | ::std::cmp::Eq,
|
5519 - | ::std::cmp::PartialEq,
|
5520 - | ::std::fmt::Debug,
|
5521 - | ::std::hash::Hash,
|
5522 - | )]
|
5523 - | pub struct Member(pub(crate) ::std::string::String);
|
5524 - | impl Member {
|
5525 - | /// Extracts a string slice containing the entire underlying `String`.
|
5526 - | pub fn as_str(&self) -> &str {
|
5527 - | &self.0
|
5528 - | }
|
5529 - |
|
5530 - | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
5531 - | pub fn inner(&self) -> &::std::string::String {
|
5532 - | &self.0
|
5533 - | }
|
5534 - |
|
5535 - | /// Consumes the value, returning the underlying [`::std::string::String`].
|
5536 - | pub fn into_inner(self) -> ::std::string::String {
|
5537 - | self.0
|
5538 - | }
|
5539 - | }
|
5540 - | impl Member {
|
5541 - | fn check_pattern(
|
5542 - | string: ::std::string::String,
|
5543 - | ) -> ::std::result::Result<
|
5544 - | ::std::string::String,
|
5545 - | crate::model::pattern_list_override::member::ConstraintViolation,
|
5546 - | > {
|
5547 - | let regex = Self::compile_regex();
|
5548 - |
|
5549 - | if regex.is_match(&string) {
|
5550 - | Ok(string)
|
5551 - | } else {
|
5552 - | Err(
|
5553 - | crate::model::pattern_list_override::member::ConstraintViolation::Pattern(
|
5554 - | string,
|
5555 - | ),
|
5556 - | )
|
5557 - | }
|
5558 - | }
|
5559 - |
|
5560 - | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
5561 - | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
5562 - | pub fn compile_regex() -> &'static ::regex::Regex {
|
5563 - | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
5564 - | ::regex::Regex::new(r#"^[g-m]+$"#).expect(r#"The regular expression ^[g-m]+$ is not supported by the `regex` crate; feel free to file an issue under https://github.com/smithy-lang/smithy-rs/issues for support"#)
|
5565 - | });
|
5566 - |
|
5567 - | ®EX
|
5568 - | }
|
5569 - | }
|
5570 - | impl ::std::convert::TryFrom<::std::string::String> for Member {
|
5571 - | type Error = crate::model::pattern_list_override::member::ConstraintViolation;
|
5572 - |
|
5573 - | /// Constructs a `Member` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
5574 - | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
5575 - | let value = Self::check_pattern(value)?;
|
5576 - |
|
5577 - | Ok(Self(value))
|
5578 - | }
|
5579 - | }
|
5580 - | impl crate::constrained::Constrained for Member {
|
5581 - | type Unconstrained = ::std::string::String;
|
5582 - | }
|
5583 - |
|
5584 - | impl ::std::convert::From<::std::string::String>
|
5585 - | for crate::constrained::MaybeConstrained<crate::model::pattern_list_override::Member>
|
5586 - | {
|
5587 - | fn from(value: ::std::string::String) -> Self {
|
5588 - | Self::Unconstrained(value)
|
5589 - | }
|
5590 - | }
|
5591 - |
|
5592 - | impl ::std::fmt::Display for Member {
|
5593 - | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5594 - | self.0.fmt(f)
|
5595 - | }
|
5596 - | }
|
5597 - |
|
5598 - | impl ::std::convert::From<Member> for ::std::string::String {
|
5599 - | fn from(value: Member) -> Self {
|
5600 - | value.into_inner()
|
5601 - | }
|
5415 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5416 + | crate::model::ValidationExceptionField {
|
5417 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5418 + | path,
|
5419 + | },
|
5602 5420 | }
|
5603 - | #[cfg(test)]
|
5604 - | mod test_member {
|
5605 - | #[test]
|
5606 - | fn regex_compiles() {
|
5607 - | crate::model::pattern_list_override::Member::compile_regex();
|
5608 5421 | }
|
5609 5422 | }
|
5423 + | }
|
5424 + | /// See [`LongSet`](crate::model::LongSet).
|
5425 + | pub mod long_set {
|
5610 5426 |
|
5611 - | /// See [`PatternListOverrideMember`](crate::model::pattern_list_override::Member).
|
5612 - | pub mod member {
|
5613 - |
|
5427 + | #[allow(clippy::enum_variant_names)]
|
5614 5428 | #[derive(Debug, PartialEq)]
|
5615 5429 | pub enum ConstraintViolation {
|
5616 - | /// Error when a string doesn't satisfy its `@pattern`.
|
5617 - | /// Contains the String that failed the pattern.
|
5618 - | Pattern(String),
|
5430 + | /// Constraint violation error when the list does not contain unique items
|
5431 + | UniqueItems {
|
5432 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5433 + | /// at least two elements.
|
5434 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5435 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5436 + | /// Nothing is guaranteed about the order of the indices.
|
5437 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5438 + | /// The original vector, that contains duplicate items.
|
5439 + | original: ::std::vec::Vec<i64>,
|
5440 + | },
|
5619 5441 | }
|
5620 5442 |
|
5621 5443 | impl ::std::fmt::Display for ConstraintViolation {
|
5622 5444 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5623 5445 | let message = match self {
|
5624 - | Self::Pattern(_) => {
|
5625 - | format!(
|
5626 - | r#"Value provided for `aws.protocoltests.restjson.validation#PatternListOverrideMember` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
5627 - | r#"^[g-m]+$"#
|
5628 - | )
|
5629 - | }
|
5446 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5447 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#LongSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5630 5448 | };
|
5631 5449 | write!(f, "{message}")
|
5632 5450 | }
|
5633 5451 | }
|
5634 5452 |
|
5635 5453 | impl ::std::error::Error for ConstraintViolation {}
|
5636 5454 | impl ConstraintViolation {
|
5637 5455 | pub(crate) fn as_validation_exception_field(
|
5638 5456 | self,
|
5639 5457 | path: ::std::string::String,
|
5640 5458 | ) -> crate::model::ValidationExceptionField {
|
5641 5459 | match self {
|
5642 - | #[allow(unused_variables)]
|
5643 - | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
5644 - | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^[g-m]+$"#),
|
5645 - | path
|
5460 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5461 + | crate::model::ValidationExceptionField {
|
5462 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5463 + | path,
|
5646 5464 | },
|
5647 5465 | }
|
5648 5466 | }
|
5649 5467 | }
|
5650 - | }
|
5651 5468 | }
|
5652 - | pub mod pattern_union {
|
5469 + | /// See [`TimestampSet`](crate::model::TimestampSet).
|
5470 + | pub mod timestamp_set {
|
5653 5471 |
|
5654 - | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
5655 5472 | #[allow(clippy::enum_variant_names)]
|
5473 + | #[derive(Debug, PartialEq)]
|
5656 5474 | pub enum ConstraintViolation {
|
5657 - | First(crate::model::pattern_string::ConstraintViolation),
|
5658 - | Second(crate::model::pattern_string::ConstraintViolation),
|
5475 + | /// Constraint violation error when the list does not contain unique items
|
5476 + | UniqueItems {
|
5477 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5478 + | /// at least two elements.
|
5479 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5480 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5481 + | /// Nothing is guaranteed about the order of the indices.
|
5482 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5483 + | /// The original vector, that contains duplicate items.
|
5484 + | original: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
5485 + | },
|
5659 5486 | }
|
5487 + |
|
5660 5488 | impl ::std::fmt::Display for ConstraintViolation {
|
5661 5489 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5662 - | match self {
|
5663 - | Self::First(inner) => write!(f, "{inner}"),
|
5664 - | Self::Second(inner) => write!(f, "{inner}"),
|
5665 - | }
|
5490 + | let message = match self {
|
5491 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5492 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#TimestampSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5493 + | };
|
5494 + | write!(f, "{message}")
|
5666 5495 | }
|
5667 5496 | }
|
5668 5497 |
|
5669 5498 | impl ::std::error::Error for ConstraintViolation {}
|
5670 5499 | impl ConstraintViolation {
|
5671 5500 | pub(crate) fn as_validation_exception_field(
|
5672 5501 | self,
|
5673 5502 | path: ::std::string::String,
|
5674 5503 | ) -> crate::model::ValidationExceptionField {
|
5675 5504 | match self {
|
5676 - | Self::First(inner) => inner.as_validation_exception_field(path + "/first"),
|
5677 - | Self::Second(inner) => inner.as_validation_exception_field(path + "/second"),
|
5505 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5506 + | crate::model::ValidationExceptionField {
|
5507 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5508 + | path,
|
5509 + | },
|
5678 5510 | }
|
5679 5511 | }
|
5680 5512 | }
|
5681 5513 | }
|
5682 - | /// See [`PatternString`](crate::model::PatternString).
|
5683 - | pub mod pattern_string {
|
5514 + | /// See [`DateTimeSet`](crate::model::DateTimeSet).
|
5515 + | pub mod date_time_set {
|
5684 5516 |
|
5517 + | #[allow(clippy::enum_variant_names)]
|
5685 5518 | #[derive(Debug, PartialEq)]
|
5686 5519 | pub enum ConstraintViolation {
|
5687 - | /// Error when a string doesn't satisfy its `@pattern`.
|
5688 - | /// Contains the String that failed the pattern.
|
5689 - | Pattern(String),
|
5520 + | /// Constraint violation error when the list does not contain unique items
|
5521 + | UniqueItems {
|
5522 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5523 + | /// at least two elements.
|
5524 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5525 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5526 + | /// Nothing is guaranteed about the order of the indices.
|
5527 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5528 + | /// The original vector, that contains duplicate items.
|
5529 + | original: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
5530 + | },
|
5690 5531 | }
|
5691 5532 |
|
5692 5533 | impl ::std::fmt::Display for ConstraintViolation {
|
5693 5534 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5694 5535 | let message = match self {
|
5695 - | Self::Pattern(_) => {
|
5696 - | format!(
|
5697 - | r#"Value provided for `aws.protocoltests.restjson.validation#PatternString` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
5698 - | r#"^[a-m]+$"#
|
5699 - | )
|
5700 - | }
|
5536 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5537 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#DateTimeSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5701 5538 | };
|
5702 5539 | write!(f, "{message}")
|
5703 5540 | }
|
5704 5541 | }
|
5705 5542 |
|
5706 5543 | impl ::std::error::Error for ConstraintViolation {}
|
5707 5544 | impl ConstraintViolation {
|
5708 5545 | pub(crate) fn as_validation_exception_field(
|
5709 5546 | self,
|
5710 5547 | path: ::std::string::String,
|
5711 5548 | ) -> crate::model::ValidationExceptionField {
|
5712 5549 | match self {
|
5713 - | #[allow(unused_variables)]
|
5714 - | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
5715 - | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^[a-m]+$"#),
|
5716 - | path
|
5550 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5551 + | crate::model::ValidationExceptionField {
|
5552 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5553 + | path,
|
5717 5554 | },
|
5718 5555 | }
|
5719 5556 | }
|
5720 5557 | }
|
5721 5558 | }
|
5722 - | pub mod pattern_map {
|
5559 + | /// See [`HttpDateSet`](crate::model::HttpDateSet).
|
5560 + | pub mod http_date_set {
|
5723 5561 |
|
5724 5562 | #[allow(clippy::enum_variant_names)]
|
5725 5563 | #[derive(Debug, PartialEq)]
|
5726 5564 | pub enum ConstraintViolation {
|
5727 - | #[doc(hidden)]
|
5728 - | Key(crate::model::pattern_string::ConstraintViolation),
|
5729 - | #[doc(hidden)]
|
5730 - | Value(
|
5731 - | crate::model::PatternString,
|
5732 - | crate::model::pattern_string::ConstraintViolation,
|
5733 - | ),
|
5565 + | /// Constraint violation error when the list does not contain unique items
|
5566 + | UniqueItems {
|
5567 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5568 + | /// at least two elements.
|
5569 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5570 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5571 + | /// Nothing is guaranteed about the order of the indices.
|
5572 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5573 + | /// The original vector, that contains duplicate items.
|
5574 + | original: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
5575 + | },
|
5734 5576 | }
|
5735 5577 |
|
5736 5578 | impl ::std::fmt::Display for ConstraintViolation {
|
5737 5579 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5738 - | match self {
|
5739 - | Self::Key(key_constraint_violation) => write!(f, "{}", key_constraint_violation),
|
5740 - | Self::Value(_, value_constraint_violation) => {
|
5741 - | write!(f, "{}", value_constraint_violation)
|
5742 - | }
|
5743 - | }
|
5580 + | let message = match self {
|
5581 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5582 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#HttpDateSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5583 + | };
|
5584 + | write!(f, "{message}")
|
5744 5585 | }
|
5745 5586 | }
|
5746 5587 |
|
5747 5588 | impl ::std::error::Error for ConstraintViolation {}
|
5748 5589 | impl ConstraintViolation {
|
5749 5590 | pub(crate) fn as_validation_exception_field(
|
5750 5591 | self,
|
5751 5592 | path: ::std::string::String,
|
5752 5593 | ) -> crate::model::ValidationExceptionField {
|
5753 5594 | match self {
|
5754 - | Self::Key(key_constraint_violation) => {
|
5755 - | key_constraint_violation.as_validation_exception_field(path)
|
5756 - | }
|
5757 - | Self::Value(key, value_constraint_violation) => value_constraint_violation
|
5758 - | .as_validation_exception_field(path + "/" + key.as_str()),
|
5595 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5596 + | crate::model::ValidationExceptionField {
|
5597 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5598 + | path,
|
5599 + | },
|
5759 5600 | }
|
5760 5601 | }
|
5761 5602 | }
|
5762 5603 | }
|
5763 - | pub mod pattern_list {
|
5604 + | /// See [`FooEnumSet`](crate::model::FooEnumSet).
|
5605 + | pub mod foo_enum_set {
|
5764 5606 |
|
5765 5607 | #[allow(clippy::enum_variant_names)]
|
5766 5608 | #[derive(Debug, PartialEq)]
|
5767 5609 | pub enum ConstraintViolation {
|
5610 + | /// Constraint violation error when the list does not contain unique items
|
5611 + | UniqueItems {
|
5612 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5613 + | /// at least two elements.
|
5614 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5615 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5616 + | /// Nothing is guaranteed about the order of the indices.
|
5617 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5618 + | /// The original vector, that contains duplicate items.
|
5619 + | original: ::std::vec::Vec<crate::model::FooEnum>,
|
5620 + | },
|
5768 5621 | /// Constraint violation error when an element doesn't satisfy its own constraints.
|
5769 5622 | /// The first component of the tuple is the index in the collection where the
|
5770 5623 | /// first constraint violation was found.
|
5771 5624 | #[doc(hidden)]
|
5772 - | Member(usize, crate::model::pattern_string::ConstraintViolation),
|
5625 + | Member(usize, crate::model::foo_enum::ConstraintViolation),
|
5773 5626 | }
|
5774 5627 |
|
5775 5628 | impl ::std::fmt::Display for ConstraintViolation {
|
5776 5629 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5777 5630 | let message = match self {
|
5778 - | Self::Member(index, failing_member) => format!(
|
5779 - | "Value at index {index} failed to satisfy constraint. {}",
|
5780 - | failing_member
|
5781 - | ),
|
5631 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5632 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#FooEnumSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5633 + | Self::Member(index, failing_member) => format!("Value at index {index} failed to satisfy constraint. {}",
|
5634 + | failing_member)
|
5782 5635 | };
|
5783 5636 | write!(f, "{message}")
|
5784 5637 | }
|
5785 5638 | }
|
5786 5639 |
|
5787 5640 | impl ::std::error::Error for ConstraintViolation {}
|
5788 5641 | impl ConstraintViolation {
|
5789 5642 | pub(crate) fn as_validation_exception_field(
|
5790 5643 | self,
|
5791 5644 | path: ::std::string::String,
|
5792 5645 | ) -> crate::model::ValidationExceptionField {
|
5793 5646 | match self {
|
5794 - | Self::Member(index, member_constraint_violation) => member_constraint_violation
|
5795 - | .as_validation_exception_field(path + "/" + &index.to_string()),
|
5647 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5648 + | crate::model::ValidationExceptionField {
|
5649 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5650 + | path,
|
5651 + | },
|
5652 + | Self::Member(index, member_constraint_violation) =>
|
5653 + | member_constraint_violation.as_validation_exception_field(path + "/" + &index.to_string())
|
5796 5654 | }
|
5797 5655 | }
|
5798 5656 | }
|
5799 5657 | }
|
5800 - | /// See [`EvilString`](crate::model::EvilString).
|
5801 - | pub mod evil_string {
|
5658 + | /// See [`IntegerEnumSet`](crate::model::IntegerEnumSet).
|
5659 + | pub mod integer_enum_set {
|
5802 5660 |
|
5661 + | #[allow(clippy::enum_variant_names)]
|
5803 5662 | #[derive(Debug, PartialEq)]
|
5804 5663 | pub enum ConstraintViolation {
|
5805 - | /// Error when a string doesn't satisfy its `@pattern`.
|
5806 - | /// Contains the String that failed the pattern.
|
5807 - | Pattern(String),
|
5664 + | /// Constraint violation error when the list does not contain unique items
|
5665 + | UniqueItems {
|
5666 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5667 + | /// at least two elements.
|
5668 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5669 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5670 + | /// Nothing is guaranteed about the order of the indices.
|
5671 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5672 + | /// The original vector, that contains duplicate items.
|
5673 + | original: ::std::vec::Vec<i32>,
|
5674 + | },
|
5808 5675 | }
|
5809 5676 |
|
5810 5677 | impl ::std::fmt::Display for ConstraintViolation {
|
5811 5678 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5812 5679 | let message = match self {
|
5813 - | Self::Pattern(_) => {
|
5814 - | format!(
|
5815 - | r#"Value provided for `aws.protocoltests.restjson.validation#EvilString` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
5816 - | r#"^([0-9]+)+$"#
|
5817 - | )
|
5818 - | }
|
5680 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5681 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#IntegerEnumSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5819 5682 | };
|
5820 5683 | write!(f, "{message}")
|
5821 5684 | }
|
5822 5685 | }
|
5823 5686 |
|
5824 5687 | impl ::std::error::Error for ConstraintViolation {}
|
5825 5688 | impl ConstraintViolation {
|
5826 5689 | pub(crate) fn as_validation_exception_field(
|
5827 5690 | self,
|
5828 5691 | path: ::std::string::String,
|
5829 5692 | ) -> crate::model::ValidationExceptionField {
|
5830 5693 | match self {
|
5831 - | #[allow(unused_variables)]
|
5832 - | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
5833 - | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^([0-9]+)+$"#),
|
5834 - | path
|
5694 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5695 + | crate::model::ValidationExceptionField {
|
5696 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5697 + | path,
|
5835 5698 | },
|
5836 5699 | }
|
5837 5700 | }
|
5838 5701 | }
|
5839 5702 | }
|
5840 - | /// See [`LengthString`](crate::model::LengthString).
|
5841 - | pub mod length_string {
|
5703 + | /// See [`ListSet`](crate::model::ListSet).
|
5704 + | pub mod list_set {
|
5842 5705 |
|
5706 + | #[allow(clippy::enum_variant_names)]
|
5843 5707 | #[derive(Debug, PartialEq)]
|
5844 5708 | pub enum ConstraintViolation {
|
5845 - | /// Error when a string doesn't satisfy its `@length` requirements.
|
5846 - | Length(usize),
|
5709 + | /// Constraint violation error when the list does not contain unique items
|
5710 + | UniqueItems {
|
5711 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5712 + | /// at least two elements.
|
5713 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5714 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5715 + | /// Nothing is guaranteed about the order of the indices.
|
5716 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5717 + | /// The original vector, that contains duplicate items.
|
5718 + | original: ::std::vec::Vec<::std::vec::Vec<::std::string::String>>,
|
5719 + | },
|
5847 5720 | }
|
5848 5721 |
|
5849 5722 | impl ::std::fmt::Display for ConstraintViolation {
|
5850 5723 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5851 5724 | let message = match self {
|
5852 - | Self::Length(length) => {
|
5853 - | format!("Value with length {} provided for 'aws.protocoltests.restjson.validation#LengthString' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length)
|
5854 - | }
|
5725 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5726 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#ListSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5855 5727 | };
|
5856 5728 | write!(f, "{message}")
|
5857 5729 | }
|
5858 5730 | }
|
5859 5731 |
|
5860 5732 | impl ::std::error::Error for ConstraintViolation {}
|
5861 5733 | impl ConstraintViolation {
|
5862 5734 | pub(crate) fn as_validation_exception_field(
|
5863 5735 | self,
|
5864 5736 | path: ::std::string::String,
|
5865 5737 | ) -> crate::model::ValidationExceptionField {
|
5866 5738 | match self {
|
5867 - | Self::Length(length) => crate::model::ValidationExceptionField {
|
5868 - | message: format!("Value with length {} at '{}' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length, &path),
|
5739 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5740 + | crate::model::ValidationExceptionField {
|
5741 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5869 5742 | path,
|
5870 5743 | },
|
5871 5744 | }
|
5872 5745 | }
|
5873 5746 | }
|
5874 5747 | }
|
5875 - | /// See [`LengthList`](crate::model::LengthList).
|
5876 - | pub mod length_list {
|
5748 + | /// See [`StructureSet`](crate::model::StructureSet).
|
5749 + | pub mod structure_set {
|
5877 5750 |
|
5878 5751 | #[allow(clippy::enum_variant_names)]
|
5879 5752 | #[derive(Debug, PartialEq)]
|
5880 5753 | pub enum ConstraintViolation {
|
5881 - | /// Constraint violation error when the list doesn't have the required length
|
5882 - | Length(usize),
|
5883 - | /// Constraint violation error when an element doesn't satisfy its own constraints.
|
5884 - | /// The first component of the tuple is the index in the collection where the
|
5885 - | /// first constraint violation was found.
|
5886 - | #[doc(hidden)]
|
5887 - | Member(usize, crate::model::length_string::ConstraintViolation),
|
5754 + | /// Constraint violation error when the list does not contain unique items
|
5755 + | UniqueItems {
|
5756 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5757 + | /// at least two elements.
|
5758 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5759 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5760 + | /// Nothing is guaranteed about the order of the indices.
|
5761 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5762 + | /// The original vector, that contains duplicate items.
|
5763 + | original: ::std::vec::Vec<crate::model::GreetingStruct>,
|
5764 + | },
|
5888 5765 | }
|
5889 5766 |
|
5890 5767 | impl ::std::fmt::Display for ConstraintViolation {
|
5891 5768 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5892 5769 | let message = match self {
|
5893 - | Self::Length(length) => {
|
5894 - | format!("Value with length {} provided for 'aws.protocoltests.restjson.validation#LengthList' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length)
|
5895 - | }
|
5896 - | Self::Member(index, failing_member) => format!(
|
5897 - | "Value at index {index} failed to satisfy constraint. {}",
|
5898 - | failing_member
|
5899 - | ),
|
5770 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5771 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#StructureSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5900 5772 | };
|
5901 5773 | write!(f, "{message}")
|
5902 5774 | }
|
5903 5775 | }
|
5904 5776 |
|
5905 5777 | impl ::std::error::Error for ConstraintViolation {}
|
5906 5778 | impl ConstraintViolation {
|
5907 5779 | pub(crate) fn as_validation_exception_field(
|
5908 5780 | self,
|
5909 5781 | path: ::std::string::String,
|
5910 5782 | ) -> crate::model::ValidationExceptionField {
|
5911 5783 | match self {
|
5912 - | Self::Length(length) => crate::model::ValidationExceptionField {
|
5913 - | message: format!("Value with length {} at '{}' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length, &path),
|
5784 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5785 + | crate::model::ValidationExceptionField {
|
5786 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5914 5787 | path,
|
5915 5788 | },
|
5916 - | Self::Member(index, member_constraint_violation) =>
|
5917 - | member_constraint_violation.as_validation_exception_field(path + "/" + &index.to_string())
|
5918 5789 | }
|
5919 5790 | }
|
5920 5791 | }
|
5921 5792 | }
|
5922 - | /// See [`LengthMap`](crate::model::LengthMap).
|
5923 - | pub mod length_map {
|
5793 + | /// See [`StructureSetWithNoKey`](crate::model::StructureSetWithNoKey).
|
5794 + | pub mod structure_set_with_no_key {
|
5924 5795 |
|
5925 5796 | #[allow(clippy::enum_variant_names)]
|
5926 5797 | #[derive(Debug, PartialEq)]
|
5927 5798 | pub enum ConstraintViolation {
|
5928 - | Length(usize),
|
5929 - | #[doc(hidden)]
|
5930 - | Key(crate::model::length_string::ConstraintViolation),
|
5799 + | /// Constraint violation error when the list does not contain unique items
|
5800 + | UniqueItems {
|
5801 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5802 + | /// at least two elements.
|
5803 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5804 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5805 + | /// Nothing is guaranteed about the order of the indices.
|
5806 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5807 + | /// The original vector, that contains duplicate items.
|
5808 + | original: ::std::vec::Vec<crate::model::MissingKeyStructure>,
|
5809 + | },
|
5810 + | /// Constraint violation error when an element doesn't satisfy its own constraints.
|
5811 + | /// The first component of the tuple is the index in the collection where the
|
5812 + | /// first constraint violation was found.
|
5931 5813 | #[doc(hidden)]
|
5932 - | Value(
|
5933 - | crate::model::LengthString,
|
5934 - | crate::model::length_list::ConstraintViolation,
|
5814 + | Member(
|
5815 + | usize,
|
5816 + | crate::model::missing_key_structure::ConstraintViolation,
|
5935 5817 | ),
|
5936 5818 | }
|
5937 5819 |
|
5938 5820 | impl ::std::fmt::Display for ConstraintViolation {
|
5939 5821 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5940 - | match self {
|
5941 - | Self::Length(length) => {
|
5942 - | write!(f, "Value with length {} provided for 'aws.protocoltests.restjson.validation#LengthMap' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length)
|
5943 - | }
|
5944 - | Self::Key(key_constraint_violation) => write!(f, "{}", key_constraint_violation),
|
5945 - | Self::Value(_, value_constraint_violation) => {
|
5946 - | write!(f, "{}", value_constraint_violation)
|
5947 - | }
|
5948 - | }
|
5822 + | let message = match self {
|
5823 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5824 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.restjson.validation#StructureSetWithNoKey' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5825 + | Self::Member(index, failing_member) => format!("Value at index {index} failed to satisfy constraint. {}",
|
5826 + | failing_member)
|
5827 + | };
|
5828 + | write!(f, "{message}")
|
5949 5829 | }
|
5950 5830 | }
|
5951 5831 |
|
5952 5832 | impl ::std::error::Error for ConstraintViolation {}
|
5953 5833 | impl ConstraintViolation {
|
5954 5834 | pub(crate) fn as_validation_exception_field(
|
5955 5835 | self,
|
5956 5836 | path: ::std::string::String,
|
5957 5837 | ) -> crate::model::ValidationExceptionField {
|
5958 5838 | match self {
|
5959 - | Self::Length(length) => crate::model::ValidationExceptionField {
|
5960 - | message: format!("Value with length {} at '{}' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length, &path),
|
5839 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5840 + | crate::model::ValidationExceptionField {
|
5841 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5961 5842 | path,
|
5962 5843 | },
|
5963 - | Self::Key(key_constraint_violation) => key_constraint_violation.as_validation_exception_field(path),
|
5964 - | Self::Value(key, value_constraint_violation) => value_constraint_violation.as_validation_exception_field(path + "/" + key.as_str()),
|
5844 + | Self::Member(index, member_constraint_violation) =>
|
5845 + | member_constraint_violation.as_validation_exception_field(path + "/" + &index.to_string())
|
5965 5846 | }
|
5966 5847 | }
|
5967 5848 | }
|
5968 5849 | }
|
5969 - | /// See [`MaxLengthString`](crate::model::MaxLengthString).
|
5970 - | pub mod max_length_string {
|
5850 + | /// See [`UnionSet`](crate::model::UnionSet).
|
5851 + | pub mod union_set {
|
5971 5852 |
|
5853 + | #[allow(clippy::enum_variant_names)]
|
5972 5854 | #[derive(Debug, PartialEq)]
|
5973 5855 | pub enum ConstraintViolation {
|
5974 - | /// Error when a string doesn't satisfy its `@length` requirements.
|
5975 - | Length(usize),
|
5856 + | /// Constraint violation error when the list does not contain unique items
|
5857 + | UniqueItems {
|
5858 + | /// A vector of indices into `original` pointing to all duplicate items. This vector has
|
5859 + | /// at least two elements.
|
5860 + | /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
|
5861 + | /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
|
5862 + | /// Nothing is guaranteed about the order of the indices.
|
5863 + | duplicate_indices: ::std::vec::Vec<usize>,
|
5864 + | /// The original vector, that contains duplicate items.
|
5865 + | original: ::std::vec::Vec<crate::model::FooUnion>,
|
5866 + | },
|
5976 5867 | }
|
5977 5868 |
|
5978 5869 | impl ::std::fmt::Display for ConstraintViolation {
|
5979 5870 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5980 5871 | let message = match self {
|
5981 - | Self::Length(length) => {
|
5982 - | format!("Value with length {} provided for 'aws.protocoltests.restjson.validation#MaxLengthString' failed to satisfy constraint: Member must have length less than or equal to 8", length)
|
5983 - | }
|
5872 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5873 + | format!("Value with repeated values at indices {:?} provided for 'aws.protocoltests.shared#UnionSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
|
5984 5874 | };
|
5985 5875 | write!(f, "{message}")
|
5986 5876 | }
|
5987 5877 | }
|
5988 5878 |
|
5989 5879 | impl ::std::error::Error for ConstraintViolation {}
|
5990 5880 | impl ConstraintViolation {
|
5991 5881 | pub(crate) fn as_validation_exception_field(
|
5992 5882 | self,
|
5993 5883 | path: ::std::string::String,
|
5994 5884 | ) -> crate::model::ValidationExceptionField {
|
5995 5885 | match self {
|
5996 - | Self::Length(length) => crate::model::ValidationExceptionField {
|
5997 - | message: format!("Value with length {} at '{}' failed to satisfy constraint: Member must have length less than or equal to 8", length, &path),
|
5886 + | Self::UniqueItems { duplicate_indices, .. } =>
|
5887 + | crate::model::ValidationExceptionField {
|
5888 + | message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
|
5998 5889 | path,
|
5999 5890 | },
|
6000 5891 | }
|
6001 5892 | }
|
6002 5893 | }
|
6003 5894 | }
|
6004 - | /// See [`MinLengthString`](crate::model::MinLengthString).
|
6005 - | pub mod min_length_string {
|
5895 + | pub mod recursive_union_one {
|
6006 5896 |
|
6007 - | #[derive(Debug, PartialEq)]
|
5897 + | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
5898 + | #[allow(clippy::enum_variant_names)]
|
6008 5899 | pub enum ConstraintViolation {
|
6009 - | /// Error when a string doesn't satisfy its `@length` requirements.
|
6010 - | Length(usize),
|
5900 + | String(crate::model::recursive_enum_string::ConstraintViolation),
|
5901 + | Union(::std::boxed::Box<crate::model::recursive_union_two::ConstraintViolation>),
|
6011 5902 | }
|
6012 - |
|
6013 5903 | impl ::std::fmt::Display for ConstraintViolation {
|
6014 5904 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
6015 - | let message = match self {
|
6016 - | Self::Length(length) => {
|
6017 - | format!("Value with length {} provided for 'aws.protocoltests.restjson.validation#MinLengthString' failed to satisfy constraint: Member must have length greater than or equal to 2", length)
|
5905 + | match self {
|
5906 + | Self::String(inner) => write!(f, "{inner}"),
|
5907 + | Self::Union(inner) => write!(f, "{inner}"),
|
6018 5908 | }
|
6019 - | };
|
6020 - | write!(f, "{message}")
|
6021 5909 | }
|
6022 5910 | }
|
6023 5911 |
|
6024 5912 | impl ::std::error::Error for ConstraintViolation {}
|
6025 5913 | impl ConstraintViolation {
|
6026 5914 | pub(crate) fn as_validation_exception_field(
|
6027 5915 | self,
|
6028 5916 | path: ::std::string::String,
|
6029 5917 | ) -> crate::model::ValidationExceptionField {
|
6030 5918 | match self {
|
6031 - | Self::Length(length) => crate::model::ValidationExceptionField {
|
6032 - | message: format!("Value with length {} at '{}' failed to satisfy constraint: Member must have length greater than or equal to 2", length, &path),
|
6033 - | path,
|
6034 - | },
|
5919 + | Self::String(inner) => inner.as_validation_exception_field(path + "/string"),
|
5920 + | Self::Union(inner) => inner.as_validation_exception_field(path + "/union"),
|
6035 5921 | }
|
6036 5922 | }
|
6037 5923 | }
|
6038 5924 | }
|
6039 - | /// See [`LengthBlob`](crate::model::LengthBlob).
|
6040 - | pub mod length_blob {
|
5925 + | /// See [`SensitivePatternString`](crate::model::SensitivePatternString).
|
5926 + | pub mod sensitive_pattern_string {
|
6041 5927 |
|
6042 5928 | #[derive(Debug, PartialEq)]
|
6043 5929 | pub enum ConstraintViolation {
|
6044 - | /// Error when a blob doesn't satisfy its `@length` requirements.
|
6045 - | Length(usize),
|
5930 + | /// Error when a string doesn't satisfy its `@pattern`.
|
5931 + | /// Contains the String that failed the pattern.
|
5932 + | Pattern(String),
|
6046 5933 | }
|
6047 5934 |
|
6048 5935 | impl ::std::fmt::Display for ConstraintViolation {
|
6049 5936 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
6050 5937 | let message = match self {
|
6051 - | Self::Length(length) => {
|
6052 - | format!("Value with length {} provided for 'aws.protocoltests.restjson.validation#LengthBlob' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length)
|
5938 + | Self::Pattern(_) => {
|
5939 + | format!(
|
5940 + | r#"Value provided for `aws.protocoltests.restjson.validation#SensitivePatternString` failed to satisfy the constraint: Member must match the regular expression pattern: {}"#,
|
5941 + | r#"^[a-m]+$"#
|
5942 + | )
|
6053 5943 | }
|
6054 5944 | };
|
6055 5945 | write!(f, "{message}")
|
6056 5946 | }
|
6057 5947 | }
|
6058 5948 |
|
6059 5949 | impl ::std::error::Error for ConstraintViolation {}
|
6060 5950 | impl ConstraintViolation {
|
6061 5951 | pub(crate) fn as_validation_exception_field(
|
6062 5952 | self,
|
6063 5953 | path: ::std::string::String,
|
6064 5954 | ) -> crate::model::ValidationExceptionField {
|
6065 5955 | match self {
|
6066 - | Self::Length(length) => crate::model::ValidationExceptionField {
|
6067 - | message: format!("Value with length {} at '{}' failed to satisfy constraint: Member must have length between 2 and 8, inclusive", length, &path),
|
6068 - | path,
|
5956 + | #[allow(unused_variables)]
|
5957 + | Self::Pattern(_) => crate::model::ValidationExceptionField {
|
5958 + | message: format!("Value at '{}' failed to satisfy constraint: Member must satisfy regular expression pattern: {}", &path, r#"^[a-m]+$"#),
|
5959 + | path
|
6069 5960 | },
|
6070 5961 | }
|
6071 5962 | }
|
6072 5963 | }
|
6073 5964 | }
|
6074 - | pub mod enum_union {
|
5965 + | /// See [`ValidationExceptionField`](crate::model::ValidationExceptionField).
|
5966 + | pub mod validation_exception_field {
|
6075 5967 |
|
6076 5968 | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
5969 + | /// Holds one variant for each of the ways the builder can fail.
|
5970 + | #[non_exhaustive]
|
6077 5971 | #[allow(clippy::enum_variant_names)]
|
6078 5972 | pub enum ConstraintViolation {
|
6079 - | First(crate::model::enum_string::ConstraintViolation),
|
6080 - | Second(crate::model::enum_string::ConstraintViolation),
|
5973 + | /// `path` was not provided but it is required when building `ValidationExceptionField`.
|
5974 + | MissingPath,
|
5975 + | /// `message` was not provided but it is required when building `ValidationExceptionField`.
|
5976 + | MissingMessage,
|
6081 5977 | }
|
6082 5978 | impl ::std::fmt::Display for ConstraintViolation {
|
6083 5979 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
6084 5980 | match self {
|
6085 - | Self::First(inner) => write!(f, "{inner}"),
|
6086 - | Self::Second(inner) => write!(f, "{inner}"),
|
5981 + | ConstraintViolation::MissingPath => write!(f, "`path` was not provided but it is required when building `ValidationExceptionField`"),
|
5982 + | ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `ValidationExceptionField`"),
|
6087 5983 | }
|
6088 5984 | }
|
6089 5985 | }
|
6090 - |
|
6091 5986 | impl ::std::error::Error for ConstraintViolation {}
|
6092 - | impl ConstraintViolation {
|
6093 - | pub(crate) fn as_validation_exception_field(
|
5987 + | impl ::std::convert::TryFrom<Builder> for crate::model::ValidationExceptionField {
|
5988 + | type Error = ConstraintViolation;
|
5989 + |
|
5990 + | fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
|
5991 + | builder.build()
|
5992 + | }
|
5993 + | }
|
5994 + | /// A builder for [`ValidationExceptionField`](crate::model::ValidationExceptionField).
|
5995 + | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
5996 + | pub struct Builder {
|
5997 + | pub(crate) path: ::std::option::Option<::std::string::String>,
|
5998 + | pub(crate) message: ::std::option::Option<::std::string::String>,
|
5999 + | }
|
6000 + | impl Builder {
|
6001 + | /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
|
6002 + | pub fn path(mut self, input: ::std::string::String) -> Self {
|
6003 + | self.path = Some(input);
|
6004 + | self
|
6005 + | }
|
6006 + | /// A detailed description of the validation failure.
|
6007 + | pub fn message(mut self, input: ::std::string::String) -> Self {
|
6008 + | self.message = Some(input);
|
6009 + | self
|
6010 + | }
|
6011 + | /// Consumes the builder and constructs a [`ValidationExceptionField`](crate::model::ValidationExceptionField).
|
6012 + | ///
|
6013 + | /// The builder fails to construct a [`ValidationExceptionField`](crate::model::ValidationExceptionField) if a [`ConstraintViolation`] occurs.
|
6014 + | ///
|
6015 + | /// If the builder fails, it will return the _first_ encountered [`ConstraintViolation`].
|
6016 + | pub fn build(self) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
|
6017 + | self.build_enforcing_all_constraints()
|
6018 + | }
|
6019 + | fn build_enforcing_all_constraints(
|
6094 6020 | self,
|
6095 - | path: ::std::string::String,
|
6096 - | ) -> crate::model::ValidationExceptionField {
|
6097 - | match self {
|
6098 - | Self::First(inner) => inner.as_validation_exception_field(path + "/first"),
|
6099 - | Self::Second(inner) => inner.as_validation_exception_field(path + "/second"),
|
6021 + | ) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
|
6022 + | Ok(crate::model::ValidationExceptionField {
|
6023 + | path: self.path.ok_or(ConstraintViolation::MissingPath)?,
|
6024 + | message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
|
6025 + | })
|
6026 + | }
|
6027 + | }
|
6028 + | }
|
6029 + | /// See [`GreetingStruct`](crate::model::GreetingStruct).
|
6030 + | pub mod greeting_struct {
|
6031 + |
|
6032 + | impl ::std::convert::From<Builder> for crate::model::GreetingStruct {
|
6033 + | fn from(builder: Builder) -> Self {
|
6034 + | builder.build()
|
6035 + | }
|
6036 + | }
|
6037 + | /// A builder for [`GreetingStruct`](crate::model::GreetingStruct).
|
6038 + | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
6039 + | pub struct Builder {
|
6040 + | pub(crate) hi: ::std::option::Option<::std::string::String>,
|
6041 + | }
|
6042 + | impl Builder {
|
6043 + | #[allow(missing_docs)] // documentation missing in model
|
6044 + | pub fn hi(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
|
6045 + | self.hi = input;
|
6046 + | self
|
6047 + | }
|
6048 + | #[allow(missing_docs)] // documentation missing in model
|
6049 + | pub(crate) fn set_hi(
|
6050 + | mut self,
|
6051 + | input: Option<impl ::std::convert::Into<::std::string::String>>,
|
6052 + | ) -> Self {
|
6053 + | self.hi = input.map(|v| v.into());
|
6054 + | self
|
6055 + | }
|
6056 + | /// Consumes the builder and constructs a [`GreetingStruct`](crate::model::GreetingStruct).
|
6057 + | pub fn build(self) -> crate::model::GreetingStruct {
|
6058 + | self.build_enforcing_all_constraints()
|
6100 6059 | }
|
6060 + | fn build_enforcing_all_constraints(self) -> crate::model::GreetingStruct {
|
6061 + | crate::model::GreetingStruct { hi: self.hi }
|
6101 6062 | }
|
6102 6063 | }
|
6103 6064 | }
|
6104 - | pub mod enum_map {
|
6065 + | /// See [`MissingKeyStructure`](crate::model::MissingKeyStructure).
|
6066 + | pub mod missing_key_structure {
|
6105 6067 |
|
6068 + | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
6069 + | /// Holds one variant for each of the ways the builder can fail.
|
6070 + | #[non_exhaustive]
|
6106 6071 | #[allow(clippy::enum_variant_names)]
|
6107 - | #[derive(Debug, PartialEq)]
|
6108 6072 | pub enum ConstraintViolation {
|
6109 - | #[doc(hidden)]
|
6110 - | Key(crate::model::enum_string::ConstraintViolation),
|
6111 - | #[doc(hidden)]
|
6112 - | Value(
|
6113 - | crate::model::EnumString,
|
6114 - | crate::model::enum_string::ConstraintViolation,
|
6115 - | ),
|
6073 + | /// `hi` was not provided but it is required when building `MissingKeyStructure`.
|
6074 + | MissingHi,
|
6116 6075 | }
|
6117 - |
|
6118 6076 | impl ::std::fmt::Display for ConstraintViolation {
|
6119 6077 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
6120 6078 | match self {
|
6121 - | Self::Key(key_constraint_violation) => write!(f, "{}", key_constraint_violation),
|
6122 - | Self::Value(_, value_constraint_violation) => {
|
6123 - | write!(f, "{}", value_constraint_violation)
|
6124 - | }
|
6079 + | ConstraintViolation::MissingHi => write!(
|
6080 + | f,
|
6081 + | "`hi` was not provided but it is required when building `MissingKeyStructure`"
|
6082 + | ),
|
6125 6083 | }
|
6126 6084 | }
|
6127 6085 | }
|
6128 - |
|
6129 6086 | impl ::std::error::Error for ConstraintViolation {}
|
6130 6087 | impl ConstraintViolation {
|
6131 6088 | pub(crate) fn as_validation_exception_field(
|
6132 6089 | self,
|
6133 6090 | path: ::std::string::String,
|
6134 6091 | ) -> crate::model::ValidationExceptionField {
|
6135 6092 | match self {
|
6136 - | Self::Key(key_constraint_violation) => {
|
6137 - | key_constraint_violation.as_validation_exception_field(path)
|
6093 + | ConstraintViolation::MissingHi => crate::model::ValidationExceptionField {
|
6094 + | message: format!(
|
6095 + | "Value at '{}/hi' failed to satisfy constraint: Member must not be null",
|
6096 + | path
|
6097 + | ),
|
6098 + | path: path + "/hi",
|
6099 + | },
|
6138 6100 | }
|
6139 - | Self::Value(key, value_constraint_violation) => value_constraint_violation
|
6140 - | .as_validation_exception_field(path + "/" + key.as_str()),
|
6141 6101 | }
|
6142 6102 | }
|
6103 + | impl ::std::convert::From<Builder>
|
6104 + | for crate::constrained::MaybeConstrained<crate::model::MissingKeyStructure>
|
6105 + | {
|
6106 + | fn from(builder: Builder) -> Self {
|
6107 + | Self::Unconstrained(builder)
|
6108 + | }
|
6109 + | }
|
6110 + | impl ::std::convert::TryFrom<Builder> for crate::model::MissingKeyStructure {
|
6111 + | type Error = ConstraintViolation;
|
6112 + |
|
6113 + | fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
|
6114 + | builder.build()
|
6115 + | }
|
6116 + | }
|
6117 + | /// A builder for [`MissingKeyStructure`](crate::model::MissingKeyStructure).
|
6118 + | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
6119 + | pub struct Builder {
|
6120 + | pub(crate) hi: ::std::option::Option<::std::string::String>,
|
6121 + | }
|
6122 + | impl Builder {
|
6123 + | #[allow(missing_docs)] // documentation missing in model
|
6124 + | pub fn hi(mut self, input: ::std::string::String) -> Self {
|
6125 + | self.hi = Some(input);
|
6126 + | self
|
6127 + | }
|
6128 + | #[allow(missing_docs)] // documentation missing in model
|
6129 + | pub(crate) fn set_hi(
|
6130 + | mut self,
|
6131 + | input: impl ::std::convert::Into<::std::string::String>,
|
6132 + | ) -> Self {
|
6133 + | self.hi = Some(input.into());
|
6134 + | self
|
6135 + | }
|
6136 + | /// Consumes the builder and constructs a [`MissingKeyStructure`](crate::model::MissingKeyStructure).
|
6137 + | ///
|
6138 + | /// The builder fails to construct a [`MissingKeyStructure`](crate::model::MissingKeyStructure) if a [`ConstraintViolation`] occurs.
|
6139 + | ///
|
6140 + | pub fn build(self) -> Result<crate::model::MissingKeyStructure, ConstraintViolation> {
|
6141 + | self.build_enforcing_all_constraints()
|
6142 + | }
|
6143 + | fn build_enforcing_all_constraints(
|
6144 + | self,
|
6145 + | ) -> Result<crate::model::MissingKeyStructure, ConstraintViolation> {
|
6146 + | Ok(crate::model::MissingKeyStructure {
|
6147 + | hi: self.hi.ok_or(ConstraintViolation::MissingHi)?,
|
6148 + | })
|
6149 + | }
|
6143 6150 | }
|
6144 6151 | }
|
6145 - | pub mod enum_list {
|
6152 + | pub mod recursive_union_two {
|
6146 6153 |
|
6154 + | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
6147 6155 | #[allow(clippy::enum_variant_names)]
|
6148 - | #[derive(Debug, PartialEq)]
|
6149 6156 | pub enum ConstraintViolation {
|
6150 - | /// Constraint violation error when an element doesn't satisfy its own constraints.
|
6151 - | /// The first component of the tuple is the index in the collection where the
|
6152 - | /// first constraint violation was found.
|
6153 - | #[doc(hidden)]
|
6154 - | Member(usize, crate::model::enum_string::ConstraintViolation),
|
6157 + | String(crate::model::recursive_enum_string::ConstraintViolation),
|
6158 + | Union(crate::model::recursive_union_one::ConstraintViolation),
|
6155 6159 | }
|
6156 - |
|
6157 6160 | impl ::std::fmt::Display for ConstraintViolation {
|
6158 6161 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
6159 - | let message = match self {
|
6160 - | Self::Member(index, failing_member) => format!(
|
6161 - | "Value at index {index} failed to satisfy constraint. {}",
|
6162 - | failing_member
|
6163 - | ),
|
6164 - | };
|
6165 - | write!(f, "{message}")
|
6162 + | match self {
|
6163 + | Self::String(inner) => write!(f, "{inner}"),
|
6164 + | Self::Union(inner) => write!(f, "{inner}"),
|
6165 + | }
|
6166 6166 | }
|
6167 6167 | }
|
6168 6168 |
|
6169 6169 | impl ::std::error::Error for ConstraintViolation {}
|
6170 6170 | impl ConstraintViolation {
|
6171 6171 | pub(crate) fn as_validation_exception_field(
|
6172 6172 | self,
|
6173 6173 | path: ::std::string::String,
|
6174 6174 | ) -> crate::model::ValidationExceptionField {
|
6175 6175 | match self {
|
6176 - | Self::Member(index, member_constraint_violation) => member_constraint_violation
|
6177 - | .as_validation_exception_field(path + "/" + &index.to_string()),
|
6176 + | Self::String(inner) => inner.as_validation_exception_field(path + "/string"),
|
6177 + | Self::Union(inner) => inner.as_validation_exception_field(path + "/union"),
|
6178 6178 | }
|
6179 6179 | }
|
6180 6180 | }
|
6181 6181 | }
|