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 + | #[allow(missing_docs)] // documentation missing in model
|
208 + | #[derive(
|
209 + | ::std::clone::Clone,
|
210 + | ::std::cmp::Eq,
|
211 + | ::std::cmp::Ord,
|
212 + | ::std::cmp::PartialEq,
|
213 + | ::std::cmp::PartialOrd,
|
214 + | ::std::fmt::Debug,
|
215 + | ::std::hash::Hash,
|
216 + | )]
|
217 + | pub enum RecursiveEnumString {
|
218 + | #[allow(missing_docs)] // documentation missing in model
|
219 + | Abc,
|
220 + | #[allow(missing_docs)] // documentation missing in model
|
221 + | Def,
|
222 + | }
|
223 + | /// See [`RecursiveEnumString`](crate::model::RecursiveEnumString).
|
224 + | pub mod recursive_enum_string {
|
225 + | #[derive(Debug, PartialEq)]
|
226 + | pub struct ConstraintViolation(pub(crate) ::std::string::String);
|
227 + |
|
228 + | impl ::std::fmt::Display for ConstraintViolation {
|
229 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
230 + | write!(
|
231 + | f,
|
232 + | r#"Value provided for 'aws.protocoltests.restjson.validation#RecursiveEnumString' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]"#
|
233 + | )
|
234 + | }
|
235 + | }
|
236 + |
|
237 + | impl ::std::error::Error for ConstraintViolation {}
|
238 + | impl ConstraintViolation {
|
239 + | pub(crate) fn as_validation_exception_field(
|
240 + | self,
|
241 + | path: ::std::string::String,
|
242 + | ) -> crate::model::ValidationExceptionField {
|
243 + | crate::model::ValidationExceptionField {
|
244 + | message: format!(
|
245 + | r#"Value at '{}' failed to satisfy constraint: Member must satisfy enum value set: [abc, def]"#,
|
246 + | &path
|
247 + | ),
|
248 + | path,
|
249 + | }
|
250 + | }
|
251 + | }
|
252 + | }
|
253 + | impl ::std::convert::TryFrom<&str> for RecursiveEnumString {
|
254 + | type Error = crate::model::recursive_enum_string::ConstraintViolation;
|
255 + | fn try_from(
|
256 + | s: &str,
|
257 + | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<&str>>::Error> {
|
258 + | 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 + | )),
|
264 + | }
|
265 + | }
|
266 + | }
|
267 + | impl ::std::convert::TryFrom<::std::string::String> for RecursiveEnumString {
|
268 + | type Error = crate::model::recursive_enum_string::ConstraintViolation;
|
269 + | fn try_from(
|
270 + | s: ::std::string::String,
|
271 + | ) -> ::std::result::Result<Self, <Self as ::std::convert::TryFrom<::std::string::String>>::Error>
|
272 + | {
|
273 + | s.as_str().try_into()
|
274 + | }
|
275 + | }
|
276 + | impl std::str::FromStr for RecursiveEnumString {
|
277 + | type Err = crate::model::recursive_enum_string::ConstraintViolation;
|
278 + | fn from_str(s: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
|
279 + | Self::try_from(s)
|
280 + | }
|
281 + | }
|
282 + | impl RecursiveEnumString {
|
283 + | /// Returns the `&str` value of the enum member.
|
284 + | pub fn as_str(&self) -> &str {
|
285 + | match self {
|
286 + | RecursiveEnumString::Abc => "abc",
|
287 + | RecursiveEnumString::Def => "def",
|
288 + | }
|
289 + | }
|
290 + | /// Returns all the `&str` representations of the enum members.
|
291 + | pub const fn values() -> &'static [&'static str] {
|
292 + | &["abc", "def"]
|
293 + | }
|
294 + | }
|
295 + | impl ::std::convert::AsRef<str> for RecursiveEnumString {
|
296 + | fn as_ref(&self) -> &str {
|
297 + | self.as_str()
|
298 + | }
|
299 + | }
|
300 + | impl crate::constrained::Constrained for RecursiveEnumString {
|
301 + | type Unconstrained = ::std::string::String;
|
302 + | }
|
303 + |
|
304 + | impl ::std::convert::From<::std::string::String>
|
305 + | for crate::constrained::MaybeConstrained<crate::model::RecursiveEnumString>
|
306 + | {
|
307 + | fn from(value: ::std::string::String) -> Self {
|
308 + | Self::Unconstrained(value)
|
309 + | }
|
310 + | }
|
311 + |
|
312 + | #[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 + | #[derive(
|
320 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
321 + | )]
|
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 + | }
|
332 + |
|
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);
|
344 + | }
|
345 + | }
|
346 + |
|
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);
|
351 + | }
|
352 + | }
|
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)
|
363 + | }
|
364 + | }
|
365 + | }
|
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.
|
370 + | 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))
|
376 + | }
|
377 + | }
|
378 + |
|
379 + | impl ::std::convert::From<UnionSet> for ::std::vec::Vec<crate::model::FooUnion> {
|
380 + | fn from(value: UnionSet) -> Self {
|
381 + | value.into_inner()
|
382 + | }
|
383 + | }
|
384 + | impl crate::constrained::Constrained for UnionSet {
|
385 + | type Unconstrained = crate::unconstrained::union_set_unconstrained::UnionSetUnconstrained;
|
386 + | }
|
387 + |
|
388 + | #[allow(missing_docs)] // documentation missing in model
|
389 + | #[derive(
|
390 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
391 + | )]
|
392 + | pub enum FooUnion {
|
393 + | #[allow(missing_docs)] // documentation missing in model
|
394 + | Integer(i32),
|
395 + | #[allow(missing_docs)] // documentation missing in model
|
396 + | String(::std::string::String),
|
397 + | }
|
398 + | impl FooUnion {
|
399 + | /// Tries to convert the enum instance into [`Integer`](crate::model::FooUnion::Integer), extracting the inner [`i32`](i32).
|
400 + | /// 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 {
|
403 + | ::std::result::Result::Ok(val)
|
404 + | } else {
|
405 + | ::std::result::Result::Err(self)
|
406 + | }
|
407 + | }
|
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()
|
411 + | }
|
412 + | /// Tries to convert the enum instance into [`String`](crate::model::FooUnion::String), extracting the inner [`String`](::std::string::String).
|
413 + | /// 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 {
|
416 + | ::std::result::Result::Ok(val)
|
417 + | } else {
|
418 + | ::std::result::Result::Err(self)
|
419 + | }
|
420 + | }
|
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()
|
424 + | }
|
425 + | }
|
426 + |
|
427 + | #[allow(missing_docs)] // documentation missing in model
|
428 + | ///
|
429 + | /// 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.
|
431 + | ///
|
432 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
433 + | ///
|
434 + | #[derive(
|
435 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
436 + | )]
|
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> {
|
441 + | &self.0
|
442 + | }
|
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> {
|
445 + | self.0
|
446 + | }
|
447 + |
|
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 + | )
|
478 + | } else {
|
479 + | Ok(items)
|
480 + | }
|
481 + | }
|
482 + | }
|
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;
|
487 + |
|
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)?;
|
493 + |
|
494 + | Ok(Self(value))
|
495 + | }
|
496 + | }
|
497 + |
|
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()
|
503 + | }
|
504 + | }
|
505 + | impl crate::constrained::Constrained for StructureSetWithNoKey {
|
506 + | type Unconstrained = crate::unconstrained::structure_set_with_no_key_unconstrained::StructureSetWithNoKeyUnconstrained;
|
507 + | }
|
508 + |
|
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()
|
528 + | }
|
529 + | }
|
530 + | impl crate::constrained::Constrained for crate::model::MissingKeyStructure {
|
531 + | type Unconstrained = crate::model::missing_key_structure::Builder;
|
532 + | }
|
533 + |
|
534 + | #[allow(missing_docs)] // documentation missing in model
|
535 + | ///
|
536 + | /// 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.
|
538 + | ///
|
539 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
540 + | ///
|
541 + | #[derive(
|
542 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
543 + | )]
|
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> {
|
548 + | &self.0
|
549 + | }
|
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 + |
|
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 + | }
|
567 + | }
|
568 + |
|
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 + | }
|
574 + | }
|
575 + | duplicate_indices.extend(last_duplicate_indices);
|
576 + |
|
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 + | )
|
585 + | } else {
|
586 + | Ok(items)
|
587 + | }
|
588 + | }
|
589 + | }
|
590 + | impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::GreetingStruct>> for StructureSet {
|
591 + | type Error = crate::model::structure_set::ConstraintViolation;
|
592 + |
|
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)?;
|
598 + |
|
599 + | Ok(Self(value))
|
600 + | }
|
601 + | }
|
602 + |
|
603 + | impl ::std::convert::From<StructureSet> for ::std::vec::Vec<crate::model::GreetingStruct> {
|
604 + | fn from(value: StructureSet) -> Self {
|
605 + | value.into_inner()
|
606 + | }
|
607 + | }
|
608 + | impl crate::constrained::Constrained for StructureSet {
|
609 + | type Unconstrained =
|
610 + | crate::unconstrained::structure_set_unconstrained::StructureSetUnconstrained;
|
611 + | }
|
612 + |
|
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()
|
625 + | }
|
626 + | }
|
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()
|
631 + | }
|
632 + | }
|
633 + | impl crate::constrained::Constrained for crate::model::GreetingStruct {
|
634 + | type Unconstrained = crate::model::greeting_struct::Builder;
|
635 + | }
|
636 + |
|
637 + | #[allow(missing_docs)] // documentation missing in model
|
638 + | ///
|
639 + | /// 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.
|
641 + | ///
|
642 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
643 + | ///
|
644 + | #[derive(
|
645 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
646 + | )]
|
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>> {
|
651 + | &self.0
|
652 + | }
|
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 + |
|
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 + | }
|
670 + | }
|
671 + |
|
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 + | }
|
677 + | }
|
678 + | duplicate_indices.extend(last_duplicate_indices);
|
679 + |
|
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 + | })
|
686 + | } else {
|
687 + | Ok(items)
|
688 + | }
|
689 + | }
|
690 + | }
|
691 + | impl ::std::convert::TryFrom<::std::vec::Vec<::std::vec::Vec<::std::string::String>>> for ListSet {
|
692 + | type Error = crate::model::list_set::ConstraintViolation;
|
693 + |
|
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)?;
|
699 + |
|
700 + | Ok(Self(value))
|
701 + | }
|
702 + | }
|
703 + |
|
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()
|
707 + | }
|
708 + | }
|
709 + | impl crate::constrained::Constrained for ListSet {
|
710 + | type Unconstrained = crate::unconstrained::list_set_unconstrained::ListSetUnconstrained;
|
711 + | }
|
712 + |
|
713 + | #[allow(missing_docs)] // documentation missing in model
|
714 + | ///
|
715 + | /// 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.
|
717 + | ///
|
718 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
719 + | ///
|
720 + | #[derive(
|
721 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
722 + | )]
|
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> {
|
727 + | &self.0
|
728 + | }
|
729 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<i32>`].
|
730 + | pub fn into_inner(self) -> ::std::vec::Vec<i32> {
|
731 + | self.0
|
732 + | }
|
733 + |
|
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 + | }
|
753 + | }
|
754 + | duplicate_indices.extend(last_duplicate_indices);
|
755 + |
|
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 + | )
|
764 + | } else {
|
765 + | Ok(items)
|
766 + | }
|
767 + | }
|
768 + | }
|
769 + | impl ::std::convert::TryFrom<::std::vec::Vec<i32>> for IntegerEnumSet {
|
770 + | type Error = crate::model::integer_enum_set::ConstraintViolation;
|
771 + |
|
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)?;
|
775 + |
|
776 + | Ok(Self(value))
|
777 + | }
|
778 + | }
|
779 + |
|
780 + | impl ::std::convert::From<IntegerEnumSet> for ::std::vec::Vec<i32> {
|
781 + | fn from(value: IntegerEnumSet) -> Self {
|
782 + | value.into_inner()
|
783 + | }
|
784 + | }
|
785 + | impl crate::constrained::Constrained for IntegerEnumSet {
|
786 + | type Unconstrained =
|
787 + | crate::unconstrained::integer_enum_set_unconstrained::IntegerEnumSetUnconstrained;
|
788 + | }
|
789 + |
|
790 + | #[allow(missing_docs)] // documentation missing in model
|
791 + | ///
|
792 + | /// 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.
|
794 + | ///
|
795 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
796 + | ///
|
797 + | #[derive(
|
798 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
799 + | )]
|
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> {
|
804 + | &self.0
|
805 + | }
|
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> {
|
808 + | self.0
|
809 + | }
|
810 + |
|
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 + | )
|
841 + | } else {
|
842 + | Ok(items)
|
843 + | }
|
844 + | }
|
845 + | }
|
846 + | impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::FooEnum>> for FooEnumSet {
|
847 + | type Error = crate::model::foo_enum_set::ConstraintViolation;
|
848 + |
|
849 + | /// Constructs a `FooEnumSet` from an [`::std::vec::Vec<crate::model::FooEnum>`], failing when the provided value does not satisfy the modeled constraints.
|
850 + | fn try_from(
|
851 + | value: ::std::vec::Vec<crate::model::FooEnum>,
|
852 + | ) -> ::std::result::Result<Self, Self::Error> {
|
853 + | let value = Self::check_unique_items(value)?;
|
854 + |
|
855 + | Ok(Self(value))
|
856 + | }
|
857 + | }
|
858 + |
|
859 + | impl ::std::convert::From<FooEnumSet> for ::std::vec::Vec<crate::model::FooEnum> {
|
860 + | fn from(value: FooEnumSet) -> Self {
|
861 + | value.into_inner()
|
862 + | }
|
863 + | }
|
864 + | impl crate::constrained::Constrained for FooEnumSet {
|
865 + | type Unconstrained = crate::unconstrained::foo_enum_set_unconstrained::FooEnumSetUnconstrained;
|
866 + | }
|
867 + |
|
868 + | #[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 + | }
|
902 + | }
|
903 + |
|
904 + | impl ::std::error::Error for ConstraintViolation {}
|
905 + | impl ConstraintViolation {
|
906 + | pub(crate) fn as_validation_exception_field(
|
907 + | 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 + | }
|
918 + | }
|
919 + | }
|
920 + | impl ::std::convert::TryFrom<&str> for FooEnum {
|
921 + | type Error = crate::model::foo_enum::ConstraintViolation;
|
922 + | 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())),
|
932 + | }
|
933 + | }
|
934 + | }
|
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()
|
942 + | }
|
943 + | }
|
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 + | }
|
981 + | }
|
982 + |
|
983 + | #[allow(missing_docs)] // documentation missing in model
|
984 + | ///
|
985 + | /// 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.
|
987 + | ///
|
988 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
989 + | ///
|
990 + | #[derive(
|
991 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
992 + | )]
|
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> {
|
997 + | &self.0
|
998 + | }
|
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
|
1002 + | }
|
1003 + |
|
1004 + | fn check_unique_items(
|
1005 + | items: ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
1006 + | ) -> ::std::result::Result<
|
1007 + | ::std::vec::Vec<::aws_smithy_types::DateTime>,
|
1008 + | crate::model::http_date_set::ConstraintViolation,
|
1009 + | > {
|
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 + | }
|
1017 + |
|
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);
|
1022 + | }
|
1023 + | }
|
1024 + | duplicate_indices.extend(last_duplicate_indices);
|
1025 + |
|
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 + | }
|
1037 + | }
|
1038 + | }
|
1039 + | impl ::std::convert::TryFrom<::std::vec::Vec<::aws_smithy_types::DateTime>> for HttpDateSet {
|
1040 + | type Error = crate::model::http_date_set::ConstraintViolation;
|
1041 + |
|
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)?;
|
1047 + |
|
1048 + | Ok(Self(value))
|
1049 + | }
|
1050 + | }
|
1051 + |
|
1052 + | impl ::std::convert::From<HttpDateSet> for ::std::vec::Vec<::aws_smithy_types::DateTime> {
|
1053 + | fn from(value: HttpDateSet) -> Self {
|
1054 + | value.into_inner()
|
1055 + | }
|
1056 + | }
|
1057 + | impl crate::constrained::Constrained for HttpDateSet {
|
1058 + | type Unconstrained =
|
1059 + | crate::unconstrained::http_date_set_unconstrained::HttpDateSetUnconstrained;
|
1060 + | }
|
1061 + |
|
1062 + | #[allow(missing_docs)] // documentation missing in model
|
1063 + | ///
|
1064 + | /// 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.
|
1066 + | ///
|
1067 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1068 + | ///
|
1069 + | #[derive(
|
1070 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1071 + | )]
|
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> {
|
1076 + | &self.0
|
1077 + | }
|
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 + |
|
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 + | }
|
1095 + | }
|
1096 + |
|
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 + | }
|
1102 + | }
|
1103 + | duplicate_indices.extend(last_duplicate_indices);
|
1104 + |
|
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 + | )
|
1113 + | } else {
|
1114 + | Ok(items)
|
1115 + | }
|
1116 + | }
|
1117 + | }
|
1118 + | impl ::std::convert::TryFrom<::std::vec::Vec<::aws_smithy_types::DateTime>> for DateTimeSet {
|
1119 + | type Error = crate::model::date_time_set::ConstraintViolation;
|
1120 + |
|
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)?;
|
1126 + |
|
1127 + | Ok(Self(value))
|
1128 + | }
|
1129 + | }
|
1130 + |
|
1131 + | impl ::std::convert::From<DateTimeSet> for ::std::vec::Vec<::aws_smithy_types::DateTime> {
|
1132 + | fn from(value: DateTimeSet) -> Self {
|
1133 + | value.into_inner()
|
1134 + | }
|
1135 + | }
|
1136 + | impl crate::constrained::Constrained for DateTimeSet {
|
1137 + | type Unconstrained =
|
1138 + | crate::unconstrained::date_time_set_unconstrained::DateTimeSetUnconstrained;
|
1139 + | }
|
1140 + |
|
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
|
1160 + | }
|
1161 + |
|
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 + | }
|
1174 + | }
|
1175 + |
|
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);
|
1180 + | }
|
1181 + | }
|
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 + | )
|
1192 + | } else {
|
1193 + | Ok(items)
|
1194 + | }
|
1195 + | }
|
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))
|
1207 + | }
|
1208 + | }
|
1209 + |
|
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 + | }
|
1214 + | }
|
1215 + | impl crate::constrained::Constrained for TimestampSet {
|
1216 + | type Unconstrained =
|
1217 + | crate::unconstrained::timestamp_set_unconstrained::TimestampSetUnconstrained;
|
1218 + | }
|
1219 + |
|
1220 + | #[allow(missing_docs)] // documentation missing in model
|
1221 + | ///
|
1222 + | /// 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.
|
1224 + | ///
|
1225 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1226 + | ///
|
1227 + | #[derive(
|
1228 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1229 + | )]
|
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> {
|
1234 + | &self.0
|
1235 + | }
|
1236 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<i64>`].
|
1237 + | pub fn into_inner(self) -> ::std::vec::Vec<i64> {
|
1238 + | self.0
|
1239 + | }
|
1240 + |
|
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 + | }
|
1252 + |
|
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);
|
1257 + | }
|
1258 + | }
|
1259 + | duplicate_indices.extend(last_duplicate_indices);
|
1260 + |
|
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 + | })
|
1267 + | } else {
|
1268 + | Ok(items)
|
1269 + | }
|
1270 + | }
|
1271 + | }
|
1272 + | impl ::std::convert::TryFrom<::std::vec::Vec<i64>> for LongSet {
|
1273 + | type Error = crate::model::long_set::ConstraintViolation;
|
1274 + |
|
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)?;
|
1278 + |
|
1279 + | Ok(Self(value))
|
1280 + | }
|
1281 + | }
|
1282 + |
|
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 + | #[allow(missing_docs)] // documentation missing in model
|
1293 + | ///
|
1294 + | /// 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.
|
1296 + | ///
|
1297 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1298 + | ///
|
1299 + | #[derive(
|
1300 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1301 + | )]
|
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> {
|
1306 + | &self.0
|
1307 + | }
|
1308 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<i32>`].
|
1309 + | pub fn into_inner(self) -> ::std::vec::Vec<i32> {
|
1310 + | self.0
|
1311 + | }
|
1312 + |
|
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);
|
1322 + | }
|
1323 + | }
|
1324 + |
|
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 + | }
|
1330 + | }
|
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 + | )
|
1341 + | } else {
|
1342 + | Ok(items)
|
1343 + | }
|
1344 + | }
|
1345 + | }
|
1346 + | impl ::std::convert::TryFrom<::std::vec::Vec<i32>> for IntegerSet {
|
1347 + | type Error = crate::model::integer_set::ConstraintViolation;
|
1348 + |
|
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)?;
|
1352 + |
|
1353 + | Ok(Self(value))
|
1354 + | }
|
1355 + | }
|
1356 + |
|
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 + | #[allow(missing_docs)] // documentation missing in model
|
1367 + | ///
|
1368 + | /// 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.
|
1370 + | ///
|
1371 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1372 + | ///
|
1373 + | #[derive(
|
1374 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1375 + | )]
|
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> {
|
1380 + | &self.0
|
1381 + | }
|
1382 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<i16>`].
|
1383 + | pub fn into_inner(self) -> ::std::vec::Vec<i16> {
|
1384 + | self.0
|
1385 + | }
|
1386 + |
|
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 + | }
|
1398 + |
|
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);
|
1403 + | }
|
1404 + | }
|
1405 + | duplicate_indices.extend(last_duplicate_indices);
|
1406 + |
|
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 + | })
|
1413 + | } else {
|
1414 + | Ok(items)
|
1415 + | }
|
1416 + | }
|
1417 + | }
|
1418 + | impl ::std::convert::TryFrom<::std::vec::Vec<i16>> for ShortSet {
|
1419 + | type Error = crate::model::short_set::ConstraintViolation;
|
1420 + |
|
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)?;
|
1424 + |
|
1425 + | Ok(Self(value))
|
1426 + | }
|
1427 + | }
|
1428 + |
|
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 + | #[allow(missing_docs)] // documentation missing in model
|
1439 + | ///
|
1440 + | /// 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.
|
1442 + | ///
|
1443 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1444 + | ///
|
1445 + | #[derive(
|
1446 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1447 + | )]
|
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> {
|
1452 + | &self.0
|
1453 + | }
|
1454 + | /// Consumes the value, returning the underlying [`::std::vec::Vec<i8>`].
|
1455 + | pub fn into_inner(self) -> ::std::vec::Vec<i8> {
|
1456 + | self.0
|
1457 + | }
|
1458 + |
|
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 + | }
|
1470 + |
|
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);
|
1475 + | }
|
1476 + | }
|
1477 + | duplicate_indices.extend(last_duplicate_indices);
|
1478 + |
|
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 + | })
|
1485 + | } else {
|
1486 + | Ok(items)
|
1487 + | }
|
1488 + | }
|
1489 + | }
|
1490 + | impl ::std::convert::TryFrom<::std::vec::Vec<i8>> for ByteSet {
|
1491 + | type Error = crate::model::byte_set::ConstraintViolation;
|
1492 + |
|
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)?;
|
1496 + |
|
1497 + | Ok(Self(value))
|
1498 + | }
|
1499 + | }
|
1500 + |
|
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 + | #[allow(missing_docs)] // documentation missing in model
|
1511 + | ///
|
1512 + | /// 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.
|
1514 + | ///
|
1515 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1516 + | ///
|
1517 + | #[derive(
|
1518 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1519 + | )]
|
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> {
|
1524 + | &self.0
|
1525 + | }
|
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> {
|
1528 + | self.0
|
1529 + | }
|
1530 + |
|
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 + | }
|
1544 + |
|
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);
|
1549 + | }
|
1550 + | }
|
1551 + | duplicate_indices.extend(last_duplicate_indices);
|
1552 + |
|
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 + | })
|
1559 + | } else {
|
1560 + | Ok(items)
|
1561 + | }
|
1562 + | }
|
1563 + | }
|
1564 + | impl ::std::convert::TryFrom<::std::vec::Vec<::std::string::String>> for StringSet {
|
1565 + | type Error = crate::model::string_set::ConstraintViolation;
|
1566 + |
|
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)?;
|
1572 + |
|
1573 + | Ok(Self(value))
|
1574 + | }
|
1575 + | }
|
1576 + |
|
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 + | #[allow(missing_docs)] // documentation missing in model
|
1587 + | ///
|
1588 + | /// 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.
|
1590 + | ///
|
1591 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1592 + | ///
|
1593 + | #[derive(
|
1594 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1595 + | )]
|
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> {
|
1600 + | &self.0
|
1601 + | }
|
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 + |
|
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 + | }
|
1617 + | }
|
1618 + |
|
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);
|
1626 + |
|
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 + | }
|
1638 + | }
|
1639 + | }
|
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 + |
|
1647 + | Ok(Self(value))
|
1648 + | }
|
1649 + | }
|
1650 + |
|
1651 + | impl ::std::convert::From<BooleanSet> for ::std::vec::Vec<bool> {
|
1652 + | fn from(value: BooleanSet) -> Self {
|
1653 + | value.into_inner()
|
1654 + | }
|
1655 + | }
|
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 + | })
|
1709 + | } else {
|
1710 + | Ok(items)
|
1711 + | }
|
1712 + | }
|
1713 + | }
|
1714 + | impl ::std::convert::TryFrom<::std::vec::Vec<::aws_smithy_types::Blob>> for BlobSet {
|
1715 + | type Error = crate::model::blob_set::ConstraintViolation;
|
1716 + |
|
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)?;
|
1722 + |
|
1723 + | Ok(Self(value))
|
1724 + | }
|
1725 + | }
|
1726 + |
|
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 + | #[allow(missing_docs)] // documentation missing in model
|
1737 + | ///
|
1738 + | /// 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.
|
1740 + | ///
|
1741 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1742 + | ///
|
1743 + | #[derive(
|
1744 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1745 + | )]
|
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 {
|
1750 + | &self.0
|
1751 + | }
|
1752 + |
|
1753 + | /// Consumes the value, returning the underlying [`i64`].
|
1754 + | pub fn into_inner(self) -> i64 {
|
1755 + | self.0
|
1756 + | }
|
1757 + | }
|
1758 + |
|
1759 + | impl crate::constrained::Constrained for MaxLong {
|
1760 + | type Unconstrained = i64;
|
1761 + | }
|
1762 + |
|
1763 + | impl ::std::convert::From<i64> for crate::constrained::MaybeConstrained<crate::model::MaxLong> {
|
1764 + | fn from(value: i64) -> Self {
|
1765 + | Self::Unconstrained(value)
|
1766 + | }
|
1767 + | }
|
1768 + |
|
1769 + | impl ::std::fmt::Display for MaxLong {
|
1770 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1771 + | self.0.fmt(f)
|
1772 + | }
|
1773 + | }
|
1774 + |
|
1775 + | impl ::std::convert::From<MaxLong> for i64 {
|
1776 + | fn from(value: MaxLong) -> Self {
|
1777 + | value.into_inner()
|
1778 + | }
|
1779 + | }
|
1780 + | impl MaxLong {
|
1781 + | fn check_range(
|
1782 + | value: i64,
|
1783 + | ) -> ::std::result::Result<(), crate::model::max_long::ConstraintViolation> {
|
1784 + | if value <= 8 {
|
1785 + | Ok(())
|
1786 + | } else {
|
1787 + | Err(crate::model::max_long::ConstraintViolation::Range(value))
|
1788 + | }
|
1789 + | }
|
1790 + | }
|
1791 + | impl ::std::convert::TryFrom<i64> for MaxLong {
|
1792 + | type Error = crate::model::max_long::ConstraintViolation;
|
1793 + |
|
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> {
|
1796 + | Self::check_range(value)?;
|
1797 + |
|
1798 + | Ok(Self(value))
|
1799 + | }
|
1800 + | }
|
1801 + |
|
1802 + | #[allow(missing_docs)] // documentation missing in model
|
1803 + | ///
|
1804 + | /// 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.
|
1806 + | ///
|
1807 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1808 + | ///
|
1809 + | #[derive(
|
1810 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1811 + | )]
|
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 {
|
1816 + | &self.0
|
1817 + | }
|
1818 + |
|
1819 + | /// Consumes the value, returning the underlying [`i64`].
|
1820 + | pub fn into_inner(self) -> i64 {
|
1821 + | self.0
|
1822 + | }
|
1823 + | }
|
1824 + |
|
1825 + | impl crate::constrained::Constrained for MinLong {
|
1826 + | type Unconstrained = i64;
|
1827 + | }
|
1828 + |
|
1829 + | impl ::std::convert::From<i64> for crate::constrained::MaybeConstrained<crate::model::MinLong> {
|
1830 + | fn from(value: i64) -> Self {
|
1831 + | Self::Unconstrained(value)
|
1832 + | }
|
1833 + | }
|
1834 + |
|
1835 + | impl ::std::fmt::Display for MinLong {
|
1836 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1837 + | self.0.fmt(f)
|
1838 + | }
|
1839 + | }
|
1840 + |
|
1841 + | impl ::std::convert::From<MinLong> for i64 {
|
1842 + | fn from(value: MinLong) -> Self {
|
1843 + | value.into_inner()
|
1844 + | }
|
1845 + | }
|
1846 + | impl MinLong {
|
1847 + | fn check_range(
|
1848 + | value: i64,
|
1849 + | ) -> ::std::result::Result<(), crate::model::min_long::ConstraintViolation> {
|
1850 + | if 2 <= value {
|
1851 + | Ok(())
|
1852 + | } 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))
|
1920 + | }
|
1921 + | }
|
1922 + | }
|
1923 + | impl ::std::convert::TryFrom<i64> for RangeLong {
|
1924 + | type Error = crate::model::range_long::ConstraintViolation;
|
1925 + |
|
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> {
|
1928 + | Self::check_range(value)?;
|
1929 + |
|
1930 + | Ok(Self(value))
|
1931 + | }
|
1932 + | }
|
1933 + |
|
1934 + | #[allow(missing_docs)] // documentation missing in model
|
1935 + | ///
|
1936 + | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
1937 + | /// [constraint traits]. Use [`MaxInteger::try_from`] to construct values of this type.
|
1938 + | ///
|
1939 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
1940 + | ///
|
1941 + | #[derive(
|
1942 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
1943 + | )]
|
1944 + | pub struct MaxInteger(pub(crate) i32);
|
1945 + | impl MaxInteger {
|
1946 + | /// Returns an immutable reference to the underlying [`i32`].
|
1947 + | pub fn inner(&self) -> &i32 {
|
1948 + | &self.0
|
1949 + | }
|
1950 + |
|
1951 + | /// Consumes the value, returning the underlying [`i32`].
|
1952 + | pub fn into_inner(self) -> i32 {
|
1953 + | self.0
|
1954 + | }
|
1955 + | }
|
1956 + |
|
1957 + | impl crate::constrained::Constrained for MaxInteger {
|
1958 + | type Unconstrained = i32;
|
1959 + | }
|
1960 + |
|
1961 + | impl ::std::convert::From<i32> for crate::constrained::MaybeConstrained<crate::model::MaxInteger> {
|
1962 + | fn from(value: i32) -> Self {
|
1963 + | Self::Unconstrained(value)
|
1964 + | }
|
1965 + | }
|
1966 + |
|
1967 + | impl ::std::fmt::Display for MaxInteger {
|
1968 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1969 + | self.0.fmt(f)
|
1970 + | }
|
1971 + | }
|
1972 + |
|
1973 + | impl ::std::convert::From<MaxInteger> for i32 {
|
1974 + | fn from(value: MaxInteger) -> Self {
|
1975 + | value.into_inner()
|
1976 + | }
|
1977 + | }
|
1978 + | impl MaxInteger {
|
1979 + | fn check_range(
|
1980 + | value: i32,
|
1981 + | ) -> ::std::result::Result<(), crate::model::max_integer::ConstraintViolation> {
|
1982 + | if value <= 8 {
|
1983 + | Ok(())
|
1984 + | } else {
|
1985 + | Err(crate::model::max_integer::ConstraintViolation::Range(value))
|
1986 + | }
|
1987 + | }
|
1988 + | }
|
1989 + | impl ::std::convert::TryFrom<i32> for MaxInteger {
|
1990 + | type Error = crate::model::max_integer::ConstraintViolation;
|
1991 + |
|
1992 + | /// Constructs a `MaxInteger` from an [`i32`], failing when the provided value does not satisfy the modeled constraints.
|
1993 + | fn try_from(value: i32) -> ::std::result::Result<Self, Self::Error> {
|
1994 + | Self::check_range(value)?;
|
1995 + |
|
1996 + | Ok(Self(value))
|
1997 + | }
|
1998 + | }
|
1999 + |
|
2000 + | #[allow(missing_docs)] // documentation missing in model
|
2001 + | ///
|
2002 + | /// 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.
|
2004 + | ///
|
2005 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2006 + | ///
|
2007 + | #[derive(
|
2008 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2009 + | )]
|
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 {
|
2014 + | &self.0
|
2015 + | }
|
2016 + |
|
2017 + | /// Consumes the value, returning the underlying [`i32`].
|
2018 + | pub fn into_inner(self) -> i32 {
|
2019 + | self.0
|
2020 + | }
|
2021 + | }
|
2022 + |
|
2023 + | impl crate::constrained::Constrained for MinInteger {
|
2024 + | type Unconstrained = i32;
|
2025 + | }
|
2026 + |
|
2027 + | impl ::std::convert::From<i32> for crate::constrained::MaybeConstrained<crate::model::MinInteger> {
|
2028 + | fn from(value: i32) -> Self {
|
2029 + | Self::Unconstrained(value)
|
2030 + | }
|
2031 + | }
|
2032 + |
|
2033 + | impl ::std::fmt::Display for MinInteger {
|
2034 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2035 + | self.0.fmt(f)
|
2036 + | }
|
2037 + | }
|
2038 + |
|
2039 + | impl ::std::convert::From<MinInteger> for i32 {
|
2040 + | fn from(value: MinInteger) -> Self {
|
2041 + | value.into_inner()
|
2042 + | }
|
2043 + | }
|
2044 + | impl MinInteger {
|
2045 + | fn check_range(
|
2046 + | value: i32,
|
2047 + | ) -> ::std::result::Result<(), crate::model::min_integer::ConstraintViolation> {
|
2048 + | if 2 <= value {
|
2049 + | Ok(())
|
2050 + | } else {
|
2051 + | Err(crate::model::min_integer::ConstraintViolation::Range(value))
|
2052 + | }
|
2053 + | }
|
2054 + | }
|
2055 + | impl ::std::convert::TryFrom<i32> for MinInteger {
|
2056 + | type Error = crate::model::min_integer::ConstraintViolation;
|
2057 + |
|
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> {
|
2060 + | Self::check_range(value)?;
|
2061 + |
|
2062 + | Ok(Self(value))
|
2063 + | }
|
2064 + | }
|
2065 + |
|
2066 + | #[allow(missing_docs)] // documentation missing in model
|
2067 + | ///
|
2068 + | /// 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.
|
2070 + | ///
|
2071 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2072 + | ///
|
2073 + | #[derive(
|
2074 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2075 + | )]
|
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 {
|
2080 + | &self.0
|
2081 + | }
|
2082 + |
|
2083 + | /// Consumes the value, returning the underlying [`i32`].
|
2084 + | pub fn into_inner(self) -> i32 {
|
2085 + | self.0
|
2086 + | }
|
2087 + | }
|
2088 + |
|
2089 + | impl crate::constrained::Constrained for RangeInteger {
|
2090 + | type Unconstrained = i32;
|
2091 + | }
|
2092 + |
|
2093 + | impl ::std::convert::From<i32>
|
2094 + | for crate::constrained::MaybeConstrained<crate::model::RangeInteger>
|
2095 + | {
|
2096 + | fn from(value: i32) -> Self {
|
2097 + | Self::Unconstrained(value)
|
2098 + | }
|
2099 + | }
|
2100 + |
|
2101 + | impl ::std::fmt::Display for RangeInteger {
|
2102 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2103 + | self.0.fmt(f)
|
2104 + | }
|
2105 + | }
|
2106 + |
|
2107 + | impl ::std::convert::From<RangeInteger> for i32 {
|
2108 + | fn from(value: RangeInteger) -> Self {
|
2109 + | value.into_inner()
|
2110 + | }
|
2111 + | }
|
2112 + | impl RangeInteger {
|
2113 + | fn check_range(
|
2114 + | value: i32,
|
2115 + | ) -> ::std::result::Result<(), crate::model::range_integer::ConstraintViolation> {
|
2116 + | if (2..=8).contains(&value) {
|
2117 + | Ok(())
|
2118 + | } else {
|
2119 + | Err(crate::model::range_integer::ConstraintViolation::Range(
|
2120 + | value,
|
2121 + | ))
|
2122 + | }
|
2123 + | }
|
2124 + | }
|
2125 + | impl ::std::convert::TryFrom<i32> for RangeInteger {
|
2126 + | type Error = crate::model::range_integer::ConstraintViolation;
|
2127 + |
|
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> {
|
2130 + | Self::check_range(value)?;
|
2131 + |
|
2132 + | Ok(Self(value))
|
2133 + | }
|
2134 + | }
|
2135 + |
|
2136 + | #[allow(missing_docs)] // documentation missing in model
|
2137 + | ///
|
2138 + | /// 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.
|
2140 + | ///
|
2141 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2142 + | ///
|
2143 + | #[derive(
|
2144 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2145 + | )]
|
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 {
|
2150 + | &self.0
|
2151 + | }
|
2152 + |
|
2153 + | /// Consumes the value, returning the underlying [`i16`].
|
2154 + | pub fn into_inner(self) -> i16 {
|
2155 + | self.0
|
2156 + | }
|
2157 + | }
|
2158 + |
|
2159 + | impl crate::constrained::Constrained for MaxShort {
|
2160 + | type Unconstrained = i16;
|
2161 + | }
|
2162 + |
|
2163 + | impl ::std::convert::From<i16> for crate::constrained::MaybeConstrained<crate::model::MaxShort> {
|
2164 + | fn from(value: i16) -> Self {
|
2165 + | Self::Unconstrained(value)
|
2166 + | }
|
2167 + | }
|
2168 + |
|
2169 + | impl ::std::fmt::Display for MaxShort {
|
2170 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2171 + | self.0.fmt(f)
|
2172 + | }
|
2173 + | }
|
2174 + |
|
2175 + | impl ::std::convert::From<MaxShort> for i16 {
|
2176 + | fn from(value: MaxShort) -> Self {
|
2177 + | value.into_inner()
|
2178 + | }
|
2179 + | }
|
2180 + | impl MaxShort {
|
2181 + | fn check_range(
|
2182 + | value: i16,
|
2183 + | ) -> ::std::result::Result<(), crate::model::max_short::ConstraintViolation> {
|
2184 + | if value <= 8 {
|
2185 + | Ok(())
|
2186 + | } else {
|
2187 + | Err(crate::model::max_short::ConstraintViolation::Range(value))
|
2188 + | }
|
2189 + | }
|
2190 + | }
|
2191 + | impl ::std::convert::TryFrom<i16> for MaxShort {
|
2192 + | type Error = crate::model::max_short::ConstraintViolation;
|
2193 + |
|
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> {
|
2196 + | Self::check_range(value)?;
|
2197 + |
|
2198 + | Ok(Self(value))
|
2199 + | }
|
2200 + | }
|
2201 + |
|
2202 + | #[allow(missing_docs)] // documentation missing in model
|
2203 + | ///
|
2204 + | /// 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.
|
2206 + | ///
|
2207 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2208 + | ///
|
2209 + | #[derive(
|
2210 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2211 + | )]
|
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 {
|
2216 + | &self.0
|
2217 + | }
|
2218 + |
|
2219 + | /// Consumes the value, returning the underlying [`i16`].
|
2220 + | pub fn into_inner(self) -> i16 {
|
2221 + | self.0
|
2222 + | }
|
2223 + | }
|
2224 + |
|
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)
|
2238 + | }
|
2239 + | }
|
2240 + |
|
2241 + | impl ::std::convert::From<MinShort> for i16 {
|
2242 + | fn from(value: MinShort) -> Self {
|
2243 + | value.into_inner()
|
2244 + | }
|
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(())
|
2252 + | } else {
|
2253 + | Err(crate::model::min_short::ConstraintViolation::Range(value))
|
2254 + | }
|
2255 + | }
|
2256 + | }
|
2257 + | impl ::std::convert::TryFrom<i16> for MinShort {
|
2258 + | type Error = crate::model::min_short::ConstraintViolation;
|
2259 + |
|
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)?;
|
2263 + |
|
2264 + | Ok(Self(value))
|
2265 + | }
|
2266 + | }
|
2267 + |
|
2268 + | #[allow(missing_docs)] // documentation missing in model
|
2269 + | ///
|
2270 + | /// 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.
|
2272 + | ///
|
2273 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2274 + | ///
|
2275 + | #[derive(
|
2276 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2277 + | )]
|
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 {
|
2282 + | &self.0
|
2283 + | }
|
2284 + |
|
2285 + | /// Consumes the value, returning the underlying [`i16`].
|
2286 + | pub fn into_inner(self) -> i16 {
|
2287 + | self.0
|
2288 + | }
|
2289 + | }
|
2290 + |
|
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)
|
2298 + | }
|
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 + | }
|
2305 + | }
|
2306 + |
|
2307 + | impl ::std::convert::From<RangeShort> for i16 {
|
2308 + | fn from(value: RangeShort) -> Self {
|
2309 + | value.into_inner()
|
2310 + | }
|
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(())
|
2318 + | } else {
|
2319 + | Err(crate::model::range_short::ConstraintViolation::Range(value))
|
2320 + | }
|
2321 + | }
|
2322 + | }
|
2323 + | impl ::std::convert::TryFrom<i16> for RangeShort {
|
2324 + | type Error = crate::model::range_short::ConstraintViolation;
|
2325 + |
|
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)?;
|
2329 + |
|
2330 + | Ok(Self(value))
|
2331 + | }
|
2332 + | }
|
2333 + |
|
2334 + | #[allow(missing_docs)] // documentation missing in model
|
2335 + | ///
|
2336 + | /// 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.
|
2338 + | ///
|
2339 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2340 + | ///
|
2341 + | #[derive(
|
2342 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2343 + | )]
|
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 {
|
2348 + | &self.0
|
2349 + | }
|
2350 + |
|
2351 + | /// Consumes the value, returning the underlying [`i8`].
|
2352 + | pub fn into_inner(self) -> i8 {
|
2353 + | self.0
|
2354 + | }
|
2355 + | }
|
2356 + |
|
2357 + | impl crate::constrained::Constrained for MaxByte {
|
2358 + | type Unconstrained = i8;
|
2359 + | }
|
2360 + |
|
2361 + | impl ::std::convert::From<i8> for crate::constrained::MaybeConstrained<crate::model::MaxByte> {
|
2362 + | fn from(value: i8) -> Self {
|
2363 + | Self::Unconstrained(value)
|
2364 + | }
|
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 + | }
|
2371 + | }
|
2372 + |
|
2373 + | impl ::std::convert::From<MaxByte> for i8 {
|
2374 + | fn from(value: MaxByte) -> Self {
|
2375 + | value.into_inner()
|
2376 + | }
|
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(())
|
2384 + | } else {
|
2385 + | Err(crate::model::max_byte::ConstraintViolation::Range(value))
|
2386 + | }
|
2387 + | }
|
2388 + | }
|
2389 + | impl ::std::convert::TryFrom<i8> for MaxByte {
|
2390 + | type Error = crate::model::max_byte::ConstraintViolation;
|
2391 + |
|
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)?;
|
2395 + |
|
2396 + | Ok(Self(value))
|
2397 + | }
|
2398 + | }
|
2399 + |
|
2400 + | #[allow(missing_docs)] // documentation missing in model
|
2401 + | ///
|
2402 + | /// 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.
|
2404 + | ///
|
2405 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2406 + | ///
|
2407 + | #[derive(
|
2408 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2409 + | )]
|
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 {
|
2414 + | &self.0
|
2415 + | }
|
2416 + |
|
2417 + | /// Consumes the value, returning the underlying [`i8`].
|
2418 + | pub fn into_inner(self) -> i8 {
|
2419 + | self.0
|
2420 + | }
|
2421 + | }
|
2422 + |
|
2423 + | impl crate::constrained::Constrained for MinByte {
|
2424 + | type Unconstrained = i8;
|
2425 + | }
|
2426 + |
|
2427 + | impl ::std::convert::From<i8> for crate::constrained::MaybeConstrained<crate::model::MinByte> {
|
2428 + | fn from(value: i8) -> Self {
|
2429 + | Self::Unconstrained(value)
|
2430 + | }
|
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 + | }
|
2437 + | }
|
2438 + |
|
2439 + | impl ::std::convert::From<MinByte> for i8 {
|
2440 + | fn from(value: MinByte) -> Self {
|
2441 + | value.into_inner()
|
2442 + | }
|
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(())
|
2450 + | } else {
|
2451 + | Err(crate::model::min_byte::ConstraintViolation::Range(value))
|
2452 + | }
|
2453 + | }
|
2454 + | }
|
2455 + | impl ::std::convert::TryFrom<i8> for MinByte {
|
2456 + | type Error = crate::model::min_byte::ConstraintViolation;
|
2457 + |
|
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)?;
|
2461 + |
|
2462 + | Ok(Self(value))
|
2463 + | }
|
2464 + | }
|
2465 + |
|
2466 + | #[allow(missing_docs)] // documentation missing in model
|
2467 + | ///
|
2468 + | /// 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.
|
2470 + | ///
|
2471 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2472 + | ///
|
2473 + | #[derive(
|
2474 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2475 + | )]
|
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 {
|
2480 + | &self.0
|
2481 + | }
|
2482 + |
|
2483 + | /// Consumes the value, returning the underlying [`i8`].
|
2484 + | pub fn into_inner(self) -> i8 {
|
2485 + | self.0
|
2486 + | }
|
2487 + | }
|
2488 + |
|
2489 + | impl crate::constrained::Constrained for RangeByte {
|
2490 + | type Unconstrained = i8;
|
2491 + | }
|
2492 + |
|
2493 + | impl ::std::convert::From<i8> for crate::constrained::MaybeConstrained<crate::model::RangeByte> {
|
2494 + | fn from(value: i8) -> Self {
|
2495 + | Self::Unconstrained(value)
|
2496 + | }
|
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 + | }
|
2503 + | }
|
2504 + |
|
2505 + | impl ::std::convert::From<RangeByte> for i8 {
|
2506 + | fn from(value: RangeByte) -> Self {
|
2507 + | value.into_inner()
|
2508 + | }
|
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(())
|
2516 + | } else {
|
2517 + | Err(crate::model::range_byte::ConstraintViolation::Range(value))
|
2518 + | }
|
2519 + | }
|
2520 + | }
|
2521 + | impl ::std::convert::TryFrom<i8> for RangeByte {
|
2522 + | type Error = crate::model::range_byte::ConstraintViolation;
|
2523 + |
|
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)?;
|
2527 + |
|
2528 + | Ok(Self(value))
|
2529 + | }
|
2530 + | }
|
2531 + |
|
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()
|
2572 + | }
|
2573 + | }
|
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 + | }
|
2612 + | }
|
2613 + |
|
2614 + | #[allow(missing_docs)] // documentation missing in model
|
2615 + | ///
|
2616 + | /// 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.
|
2618 + | ///
|
2619 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2620 + | ///
|
2621 + | #[derive(
|
2622 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2623 + | )]
|
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 {
|
2628 + | &self.0
|
2629 + | }
|
2630 + |
|
2631 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
2632 + | pub fn inner(&self) -> &::std::string::String {
|
2633 + | &self.0
|
2634 + | }
|
2635 + |
|
2636 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
2637 + | pub fn into_inner(self) -> ::std::string::String {
|
2638 + | self.0
|
2639 + | }
|
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 + |
|
2650 + | if regex.is_match(&string) {
|
2651 + | Ok(string)
|
2652 + | } else {
|
2653 + | Err(crate::model::pattern_string::ConstraintViolation::Pattern(
|
2654 + | string,
|
2655 + | ))
|
2656 + | }
|
2657 + | }
|
2658 + |
|
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
|
2667 + | }
|
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 + | }
|
2678 + | }
|
2679 + | impl crate::constrained::Constrained for PatternString {
|
2680 + | type Unconstrained = ::std::string::String;
|
2681 + | }
|
2682 + |
|
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 + | }
|
2690 + |
|
2691 + | impl ::std::fmt::Display for PatternString {
|
2692 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2693 + | self.0.fmt(f)
|
2694 + | }
|
2695 + | }
|
2696 + |
|
2697 + | impl ::std::convert::From<PatternString> for ::std::string::String {
|
2698 + | fn from(value: PatternString) -> Self {
|
2699 + | value.into_inner()
|
2700 + | }
|
2701 + | }
|
2702 + |
|
2703 + | #[cfg(test)]
|
2704 + | mod test_pattern_string {
|
2705 + | #[test]
|
2706 + | fn regex_compiles() {
|
2707 + | crate::model::PatternString::compile_regex();
|
2708 + | }
|
2709 + | }
|
2710 + |
|
2711 + | #[allow(missing_docs)] // documentation missing in model
|
2712 + | ///
|
2713 + | /// 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.
|
2715 + | ///
|
2716 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2717 + | ///
|
2718 + | #[derive(
|
2719 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2720 + | )]
|
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 {
|
2730 + | &self.0
|
2731 + | }
|
2732 + |
|
2733 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
2734 + | pub fn into_inner(self) -> ::std::string::String {
|
2735 + | self.0
|
2736 + | }
|
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 + |
|
2745 + | if regex.is_match(&string) {
|
2746 + | Ok(string)
|
2747 + | } else {
|
2748 + | Err(crate::model::evil_string::ConstraintViolation::Pattern(
|
2749 + | string,
|
2750 + | ))
|
2751 + | }
|
2752 + | }
|
2753 + |
|
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
|
2762 + | }
|
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 + | }
|
2773 + | }
|
2774 + | impl crate::constrained::Constrained for EvilString {
|
2775 + | type Unconstrained = ::std::string::String;
|
2776 + | }
|
2777 + |
|
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)
|
2783 + | }
|
2784 + | }
|
2785 + |
|
2786 + | impl ::std::fmt::Display for EvilString {
|
2787 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2788 + | self.0.fmt(f)
|
2789 + | }
|
2790 + | }
|
2791 + |
|
2792 + | impl ::std::convert::From<EvilString> for ::std::string::String {
|
2793 + | fn from(value: EvilString) -> Self {
|
2794 + | value.into_inner()
|
2795 + | }
|
2796 + | }
|
2797 + |
|
2798 + | #[cfg(test)]
|
2799 + | mod test_evil_string {
|
2800 + | #[test]
|
2801 + | fn regex_compiles() {
|
2802 + | crate::model::EvilString::compile_regex();
|
2803 + | }
|
2804 + | }
|
2805 + |
|
2806 + | #[allow(missing_docs)] // documentation missing in model
|
2807 + | ///
|
2808 + | /// 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.
|
2810 + | ///
|
2811 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2812 + | ///
|
2813 + | #[derive(
|
2814 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2815 + | )]
|
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 {
|
2820 + | &self.0
|
2821 + | }
|
2822 + |
|
2823 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
2824 + | pub fn inner(&self) -> &::std::string::String {
|
2825 + | &self.0
|
2826 + | }
|
2827 + |
|
2828 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
2829 + | pub fn into_inner(self) -> ::std::string::String {
|
2830 + | self.0
|
2831 + | }
|
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();
|
2838 + |
|
2839 + | if (2..=8).contains(&length) {
|
2840 + | Ok(())
|
2841 + | } else {
|
2842 + | Err(crate::model::length_string::ConstraintViolation::Length(
|
2843 + | length,
|
2844 + | ))
|
2845 + | }
|
2846 + | }
|
2847 + | }
|
2848 + | impl ::std::convert::TryFrom<::std::string::String> for LengthString {
|
2849 + | type Error = crate::model::length_string::ConstraintViolation;
|
2850 + |
|
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)?;
|
2854 + |
|
2855 + | Ok(Self(value))
|
2856 + | }
|
2857 + | }
|
2858 + | impl crate::constrained::Constrained for LengthString {
|
2859 + | type Unconstrained = ::std::string::String;
|
2860 + | }
|
2861 + |
|
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)
|
2867 + | }
|
2868 + | }
|
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 + | }
|
2880 + | }
|
2881 + |
|
2882 + | #[allow(missing_docs)] // documentation missing in model
|
2883 + | ///
|
2884 + | /// 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.
|
2886 + | ///
|
2887 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2888 + | ///
|
2889 + | #[derive(
|
2890 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
2891 + | )]
|
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> {
|
2896 + | &self.0
|
2897 + | }
|
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> {
|
2900 + | self.0
|
2901 + | }
|
2902 + |
|
2903 + | fn check_length(
|
2904 + | length: usize,
|
2905 + | ) -> ::std::result::Result<(), crate::model::length_list::ConstraintViolation> {
|
2906 + | if (2..=8).contains(&length) {
|
2907 + | Ok(())
|
2908 + | } else {
|
2909 + | Err(crate::model::length_list::ConstraintViolation::Length(
|
2910 + | length,
|
2911 + | ))
|
2912 + | }
|
2913 + | }
|
2914 + | }
|
2915 + | impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::LengthString>> for LengthList {
|
2916 + | type Error = crate::model::length_list::ConstraintViolation;
|
2917 + |
|
2918 + | /// Constructs a `LengthList` from an [`::std::vec::Vec<crate::model::LengthString>`], failing when the provided value does not satisfy the modeled constraints.
|
2919 + | fn try_from(
|
2920 + | value: ::std::vec::Vec<crate::model::LengthString>,
|
2921 + | ) -> ::std::result::Result<Self, Self::Error> {
|
2922 + | Self::check_length(value.len())?;
|
2923 + |
|
2924 + | Ok(Self(value))
|
2925 + | }
|
2926 + | }
|
2927 + |
|
2928 + | impl ::std::convert::From<LengthList> for ::std::vec::Vec<crate::model::LengthString> {
|
2929 + | fn from(value: LengthList) -> Self {
|
2930 + | value.into_inner()
|
2931 + | }
|
2932 + | }
|
2933 + | impl crate::constrained::Constrained for LengthList {
|
2934 + | type Unconstrained = crate::unconstrained::length_list_unconstrained::LengthListUnconstrained;
|
2935 + | }
|
2936 + |
|
2937 + | #[allow(missing_docs)] // documentation missing in model
|
2938 + | ///
|
2939 + | /// 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.
|
2941 + | ///
|
2942 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
2943 + | ///
|
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> {
|
2953 + | &self.0
|
2954 + | }
|
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> {
|
2959 + | self.0
|
2960 + | }
|
2961 + | }
|
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;
|
2968 + |
|
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.
|
2970 + | fn try_from(
|
2971 + | value: ::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>,
|
2972 + | ) -> ::std::result::Result<Self, Self::Error> {
|
2973 + | let length = value.len();
|
2974 + | if (2..=8).contains(&length) {
|
2975 + | Ok(Self(value))
|
2976 + | } else {
|
2977 + | Err(crate::model::length_map::ConstraintViolation::Length(
|
2978 + | length,
|
2979 + | ))
|
2980 + | }
|
2981 + | }
|
2982 + | }
|
2983 + |
|
2984 + | impl ::std::convert::From<LengthMap>
|
2985 + | for ::std::collections::HashMap<crate::model::LengthString, crate::model::LengthList>
|
2986 + | {
|
2987 + | fn from(value: LengthMap) -> Self {
|
2988 + | value.into_inner()
|
2989 + | }
|
2990 + | }
|
2991 + | impl crate::constrained::Constrained for LengthMap {
|
2992 + | type Unconstrained = crate::unconstrained::length_map_unconstrained::LengthMapUnconstrained;
|
2993 + | }
|
2994 + |
|
2995 + | #[allow(missing_docs)] // documentation missing in model
|
2996 + | ///
|
2997 + | /// 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.
|
2999 + | ///
|
3000 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
3001 + | ///
|
3002 + | #[derive(
|
3003 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3004 + | )]
|
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 {
|
3009 + | &self.0
|
3010 + | }
|
3011 + |
|
3012 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
3013 + | pub fn inner(&self) -> &::std::string::String {
|
3014 + | &self.0
|
3015 + | }
|
3016 + |
|
3017 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
3018 + | pub fn into_inner(self) -> ::std::string::String {
|
3019 + | self.0
|
3020 + | }
|
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();
|
3027 + |
|
3028 + | if length <= 8 {
|
3029 + | Ok(())
|
3030 + | } else {
|
3031 + | Err(crate::model::max_length_string::ConstraintViolation::Length(length))
|
3032 + | }
|
3033 + | }
|
3034 + | }
|
3035 + | impl ::std::convert::TryFrom<::std::string::String> for MaxLengthString {
|
3036 + | type Error = crate::model::max_length_string::ConstraintViolation;
|
3037 + |
|
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)?;
|
3041 + |
|
3042 + | Ok(Self(value))
|
3043 + | }
|
3044 + | }
|
3045 + | impl crate::constrained::Constrained for MaxLengthString {
|
3046 + | type Unconstrained = ::std::string::String;
|
3047 + | }
|
3048 + |
|
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)
|
3054 + | }
|
3055 + | }
|
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 + | }
|
3067 + | }
|
3068 + |
|
3069 + | #[allow(missing_docs)] // documentation missing in model
|
3070 + | ///
|
3071 + | /// 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.
|
3073 + | ///
|
3074 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
3075 + | ///
|
3076 + | #[derive(
|
3077 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3078 + | )]
|
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 {
|
3083 + | &self.0
|
3084 + | }
|
3085 + |
|
3086 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
3087 + | pub fn inner(&self) -> &::std::string::String {
|
3088 + | &self.0
|
3089 + | }
|
3090 + |
|
3091 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
3092 + | pub fn into_inner(self) -> ::std::string::String {
|
3093 + | self.0
|
3094 + | }
|
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();
|
3101 + |
|
3102 + | if 2 <= length {
|
3103 + | Ok(())
|
3104 + | } else {
|
3105 + | Err(crate::model::min_length_string::ConstraintViolation::Length(length))
|
3106 + | }
|
3107 + | }
|
3108 + | }
|
3109 + | impl ::std::convert::TryFrom<::std::string::String> for MinLengthString {
|
3110 + | type Error = crate::model::min_length_string::ConstraintViolation;
|
3111 + |
|
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)?;
|
3115 + |
|
3116 + | Ok(Self(value))
|
3117 + | }
|
3118 + | }
|
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 + |
|
3137 + | impl ::std::convert::From<MinLengthString> for ::std::string::String {
|
3138 + | fn from(value: MinLengthString) -> Self {
|
3139 + | value.into_inner()
|
3140 + | }
|
3141 + | }
|
3142 + |
|
3143 + | #[allow(missing_docs)] // documentation missing in model
|
3144 + | ///
|
3145 + | /// 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.
|
3147 + | ///
|
3148 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
3149 + | ///
|
3150 + | #[derive(
|
3151 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3152 + | )]
|
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 {
|
3157 + | &self.0
|
3158 + | }
|
3159 + | /// Consumes the value, returning the underlying [`::aws_smithy_types::Blob`].
|
3160 + | pub fn into_inner(self) -> ::aws_smithy_types::Blob {
|
3161 + | self.0
|
3162 + | }
|
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 + |
|
3170 + | if (2..=8).contains(&length) {
|
3171 + | Ok(())
|
3172 + | } else {
|
3173 + | Err(crate::model::length_blob::ConstraintViolation::Length(
|
3174 + | length,
|
3175 + | ))
|
3176 + | }
|
3177 + | }
|
3178 + | }
|
3179 + | impl ::std::convert::TryFrom<::aws_smithy_types::Blob> for LengthBlob {
|
3180 + | type Error = crate::model::length_blob::ConstraintViolation;
|
3181 + |
|
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)?;
|
3185 + |
|
3186 + | Ok(Self(value))
|
3187 + | }
|
3188 + | }
|
3189 + | impl crate::constrained::Constrained for LengthBlob {
|
3190 + | type Unconstrained = ::aws_smithy_types::Blob;
|
3191 + | }
|
3192 + |
|
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)
|
3198 + | }
|
3199 + | }
|
3200 + |
|
3201 + | impl ::std::convert::From<LengthBlob> for ::aws_smithy_types::Blob {
|
3202 + | fn from(value: LengthBlob) -> Self {
|
3203 + | value.into_inner()
|
3204 + | }
|
3205 + | }
|
3206 + |
|
3207 + | #[allow(missing_docs)] // documentation missing in model
|
3208 + | #[derive(
|
3209 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
|
3210 + | )]
|
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)
|
3225 + | }
|
3226 + | }
|
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()
|
3230 + | }
|
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 + | }
|
3239 + | }
|
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 + | }
|
3244 + | }
|
3245 + |
|
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]"#
|
3276 + | )
|
3277 + | }
|
3278 + | }
|
3279 + |
|
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 + | }
|
3293 + | }
|
3294 + | }
|
3295 + | }
|
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())),
|
3307 + | }
|
3308 + | }
|
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()
|
3317 + | }
|
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 + | }
|
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",
|
3333 + | }
|
3334 + | }
|
3335 + | /// Returns all the `&str` representations of the enum members.
|
3336 + | pub const fn values() -> &'static [&'static str] {
|
3337 + | &["abc", "def", "ghi", "jkl"]
|
3338 + | }
|
3339 + | }
|
3340 + | impl ::std::convert::AsRef<str> for EnumString {
|
3341 + | fn as_ref(&self) -> &str {
|
3342 + | self.as_str()
|
3343 + | }
|
3344 + | }
|
3345 + | impl crate::constrained::Constrained for EnumString {
|
3346 + | type Unconstrained = ::std::string::String;
|
3347 + | }
|
3348 + |
|
3349 + | impl ::std::convert::From<::std::string::String>
|
3350 + | for crate::constrained::MaybeConstrained<crate::model::EnumString>
|
3351 + | {
|
3352 + | fn from(value: ::std::string::String) -> Self {
|
3353 + | Self::Unconstrained(value)
|
3354 + | }
|
3355 + | }
|
3356 + |
|
3357 + | #[allow(missing_docs)] // documentation missing in model
|
3358 + | #[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,
|
3366 + | )]
|
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);
|
3379 + |
|
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 + | )
|
3386 + | }
|
3387 + | }
|
3388 + |
|
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,
|
3401 + | }
|
3402 + | }
|
3403 + | }
|
3404 + | }
|
3405 + | impl ::std::convert::TryFrom<&str> for EnumTraitString {
|
3406 + | type Error = crate::model::enum_trait_string::ConstraintViolation;
|
3407 + | 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 + | }
|
3418 + | }
|
3419 + | }
|
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()
|
3427 + | }
|
3428 + | }
|
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)
|
3433 + | }
|
3434 + | }
|
3435 + | impl EnumTraitString {
|
3436 + | /// Returns the `&str` value of the enum member.
|
3437 + | pub fn as_str(&self) -> &str {
|
3438 + | match self {
|
3439 + | EnumTraitString::Abc => "abc",
|
3440 + | EnumTraitString::Def => "def",
|
3441 + | EnumTraitString::Ghi => "ghi",
|
3442 + | }
|
3443 + | }
|
3444 + | /// Returns all the `&str` representations of the enum members.
|
3445 + | pub const fn values() -> &'static [&'static str] {
|
3446 + | &["abc", "def", "ghi"]
|
3447 + | }
|
3448 + | }
|
3449 + | impl ::std::convert::AsRef<str> for EnumTraitString {
|
3450 + | fn as_ref(&self) -> &str {
|
3451 + | self.as_str()
|
3452 + | }
|
3453 + | }
|
3454 + | impl crate::constrained::Constrained for EnumTraitString {
|
3455 + | type Unconstrained = ::std::string::String;
|
3456 + | }
|
3457 + |
|
3458 + | impl ::std::convert::From<::std::string::String>
|
3459 + | for crate::constrained::MaybeConstrained<crate::model::EnumTraitString>
|
3460 + | {
|
3461 + | fn from(value: ::std::string::String) -> Self {
|
3462 + | Self::Unconstrained(value)
|
3463 + | }
|
3464 + | }
|
3465 + | /// See [`ValidationExceptionField`](crate::model::ValidationExceptionField).
|
3466 + | pub mod validation_exception_field {
|
3467 + |
|
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 {
|
3479 + | 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 + | }
|
3485 + | }
|
3486 + | impl ::std::error::Error for ConstraintViolation {}
|
3487 + | impl ::std::convert::TryFrom<Builder> for crate::model::ValidationExceptionField {
|
3488 + | type Error = ConstraintViolation;
|
3489 + |
|
3490 + | fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
|
3491 + | builder.build()
|
3492 + | }
|
3493 + | }
|
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>,
|
3499 + | }
|
3500 + | impl Builder {
|
3501 + | /// 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 + | }
|
3506 + | /// 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 + | })
|
3526 + | }
|
3527 + | }
|
3528 + | }
|
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),
|
3537 + | }
|
3538 + |
|
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 + | }
|
3568 + | }
|
3569 + | pub mod recursive_union_one {
|
3570 + |
|
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 + | impl ::std::fmt::Display for ConstraintViolation {
|
3578 + | 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 + | }
|
3583 + | }
|
3584 + | }
|
3585 + |
|
3586 + | impl ::std::error::Error for ConstraintViolation {}
|
3587 + | impl ConstraintViolation {
|
3588 + | pub(crate) fn as_validation_exception_field(
|
3589 + | self,
|
3590 + | path: ::std::string::String,
|
3591 + | ) -> 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"),
|
3595 + | }
|
3596 + | }
|
3597 + | }
|
3598 + | }
|
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),
|
3606 + | }
|
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 + | }
|
3613 + | }
|
3614 + | }
|
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 {
|
3622 + | match self {
|
3623 + | Self::String(inner) => inner.as_validation_exception_field(path + "/string"),
|
3624 + | Self::Union(inner) => inner.as_validation_exception_field(path + "/union"),
|
3625 + | }
|
3626 + | }
|
3627 + | }
|
3628 + | }
|
3629 + | /// See [`UnionSet`](crate::model::UnionSet).
|
3630 + | pub mod union_set {
|
3631 + |
|
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 + | },
|
3646 + | }
|
3647 + |
|
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}")
|
3655 + | }
|
3656 + | }
|
3657 + |
|
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 + | }
|
3671 + | }
|
3672 + | }
|
3673 + | }
|
3674 + | /// See [`StructureSetWithNoKey`](crate::model::StructureSetWithNoKey).
|
3675 + | pub mod structure_set_with_no_key {
|
3676 + |
|
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 + | ),
|
3699 + | }
|
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 + | }
|
3711 + | }
|
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())
|
3727 + | }
|
3728 + | }
|
3729 + | }
|
3730 + | }
|
3731 + | /// See [`MissingKeyStructure`](crate::model::MissingKeyStructure).
|
3732 + | pub mod missing_key_structure {
|
3733 + |
|
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 + | }
|
3742 + | impl ::std::fmt::Display for ConstraintViolation {
|
3743 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3744 + | match self {
|
3745 + | ConstraintViolation::MissingHi => write!(
|
3746 + | f,
|
3747 + | "`hi` was not provided but it is required when building `MissingKeyStructure`"
|
3748 + | ),
|
3749 + | }
|
3750 + | }
|
3751 + | }
|
3752 + | impl ::std::error::Error for ConstraintViolation {}
|
3753 + | impl ConstraintViolation {
|
3754 + | pub(crate) fn as_validation_exception_field(
|
3755 + | self,
|
3756 + | path: ::std::string::String,
|
3757 + | ) -> crate::model::ValidationExceptionField {
|
3758 + | match self {
|
3759 + | ConstraintViolation::MissingHi => crate::model::ValidationExceptionField {
|
3760 + | message: format!(
|
3761 + | "Value at '{}/hi' failed to satisfy constraint: Member must not be null",
|
3762 + | path
|
3763 + | ),
|
3764 + | path: path + "/hi",
|
3765 + | },
|
3766 + | }
|
3767 + | }
|
3768 + | }
|
3769 + | impl ::std::convert::From<Builder>
|
3770 + | for crate::constrained::MaybeConstrained<crate::model::MissingKeyStructure>
|
3771 + | {
|
3772 + | fn from(builder: Builder) -> Self {
|
3773 + | Self::Unconstrained(builder)
|
3774 + | }
|
3775 + | }
|
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()
|
3781 + | }
|
3782 + | }
|
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>,
|
3787 + | }
|
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
|
3793 + | }
|
3794 + | #[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
|
3801 + | }
|
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 + | }
|
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 + | })
|
3815 + | }
|
3816 + | }
|
3817 + | }
|
3818 + | /// See [`StructureSet`](crate::model::StructureSet).
|
3819 + | pub mod structure_set {
|
3820 + |
|
3821 + | #[allow(clippy::enum_variant_names)]
|
3822 + | #[derive(Debug, PartialEq)]
|
3823 + | 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 + | },
|
3835 + | }
|
3836 + |
|
3837 + | impl ::std::fmt::Display for ConstraintViolation {
|
3838 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
3839 + | 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),
|
3842 + | };
|
3843 + | write!(f, "{message}")
|
3844 + | }
|
3845 + | }
|
3846 + |
|
3847 + | impl ::std::error::Error for ConstraintViolation {}
|
3848 + | impl ConstraintViolation {
|
3849 + | pub(crate) fn as_validation_exception_field(
|
3850 + | self,
|
3851 + | path: ::std::string::String,
|
3852 + | ) -> crate::model::ValidationExceptionField {
|
3853 + | 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()
|
3893 + | }
|
3894 + | fn build_enforcing_all_constraints(self) -> crate::model::GreetingStruct {
|
3895 + | crate::model::GreetingStruct { hi: self.hi }
|
3896 + | }
|
3897 + | }
|
3898 + | }
|
3899 + | /// See [`ListSet`](crate::model::ListSet).
|
3900 + | pub mod list_set {
|
3901 + |
|
3902 + | #[allow(clippy::enum_variant_names)]
|
3903 + | #[derive(Debug, PartialEq)]
|
3904 + | 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 + | },
|
3916 + | }
|
3917 + |
|
3918 + | impl ::std::fmt::Display for ConstraintViolation {
|
3919 + | 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}")
|
3925 + | }
|
3926 + | }
|
3927 + |
|
3928 + | impl ::std::error::Error for ConstraintViolation {}
|
3929 + | impl ConstraintViolation {
|
3930 + | pub(crate) fn as_validation_exception_field(
|
3931 + | self,
|
3932 + | path: ::std::string::String,
|
3933 + | ) -> crate::model::ValidationExceptionField {
|
3934 + | 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 + | },
|
3940 + | }
|
3941 + | }
|
3942 + | }
|
3943 + | }
|
3944 + | /// See [`IntegerEnumSet`](crate::model::IntegerEnumSet).
|
3945 + | pub mod integer_enum_set {
|
3946 + |
|
3947 + | #[allow(clippy::enum_variant_names)]
|
3948 + | #[derive(Debug, PartialEq)]
|
3949 + | 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 + | },
|
3961 + | }
|
3962 + |
|
3963 + | impl ::std::fmt::Display for ConstraintViolation {
|
3964 + | 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}")
|
3970 + | }
|
3971 + | }
|
3972 + |
|
3973 + | impl ::std::error::Error for ConstraintViolation {}
|
3974 + | impl ConstraintViolation {
|
3975 + | pub(crate) fn as_validation_exception_field(
|
3976 + | self,
|
3977 + | path: ::std::string::String,
|
3978 + | ) -> crate::model::ValidationExceptionField {
|
3979 + | 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 + | },
|
3985 + | }
|
3986 + | }
|
3987 + | }
|
3988 + | }
|
3989 + | /// See [`FooEnumSet`](crate::model::FooEnumSet).
|
3990 + | pub mod foo_enum_set {
|
3991 + |
|
3992 + | #[allow(clippy::enum_variant_names)]
|
3993 + | #[derive(Debug, PartialEq)]
|
3994 + | 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),
|
4011 + | }
|
4012 + |
|
4013 + | impl ::std::fmt::Display for ConstraintViolation {
|
4014 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4015 + | 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)
|
4020 + | };
|
4021 + | write!(f, "{message}")
|
4022 + | }
|
4023 + | }
|
4024 + |
|
4025 + | impl ::std::error::Error for ConstraintViolation {}
|
4026 + | impl ConstraintViolation {
|
4027 + | pub(crate) fn as_validation_exception_field(
|
4028 + | self,
|
4029 + | path: ::std::string::String,
|
4030 + | ) -> crate::model::ValidationExceptionField {
|
4031 + | 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),
|
4035 + | path,
|
4036 + | },
|
4037 + | Self::Member(index, member_constraint_violation) =>
|
4038 + | member_constraint_violation.as_validation_exception_field(path + "/" + &index.to_string())
|
4039 + | }
|
4040 + | }
|
4041 + | }
|
4042 + | }
|
4043 + | /// See [`HttpDateSet`](crate::model::HttpDateSet).
|
4044 + | pub mod http_date_set {
|
4045 + |
|
4046 + | #[allow(clippy::enum_variant_names)]
|
4047 + | #[derive(Debug, PartialEq)]
|
4048 + | 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 + | },
|
4060 + | }
|
4061 + |
|
4062 + | impl ::std::fmt::Display for ConstraintViolation {
|
4063 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4064 + | 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),
|
4067 + | };
|
4068 + | write!(f, "{message}")
|
4069 + | }
|
4070 + | }
|
4071 + |
|
4072 + | impl ::std::error::Error for ConstraintViolation {}
|
4073 + | impl ConstraintViolation {
|
4074 + | pub(crate) fn as_validation_exception_field(
|
4075 + | self,
|
4076 + | path: ::std::string::String,
|
4077 + | ) -> crate::model::ValidationExceptionField {
|
4078 + | 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),
|
4082 + | path,
|
4083 + | },
|
4084 + | }
|
4085 + | }
|
4086 + | }
|
4087 + | }
|
4088 + | /// See [`DateTimeSet`](crate::model::DateTimeSet).
|
4089 + | pub mod date_time_set {
|
4090 + |
|
4091 + | #[allow(clippy::enum_variant_names)]
|
4092 + | #[derive(Debug, PartialEq)]
|
4093 + | 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 + | },
|
4105 + | }
|
4106 + |
|
4107 + | impl ::std::fmt::Display for ConstraintViolation {
|
4108 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4109 + | 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),
|
4112 + | };
|
4113 + | write!(f, "{message}")
|
4114 + | }
|
4115 + | }
|
4116 + |
|
4117 + | impl ::std::error::Error for ConstraintViolation {}
|
4118 + | impl ConstraintViolation {
|
4119 + | pub(crate) fn as_validation_exception_field(
|
4120 + | self,
|
4121 + | path: ::std::string::String,
|
4122 + | ) -> crate::model::ValidationExceptionField {
|
4123 + | 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),
|
4127 + | path,
|
4128 + | },
|
4129 + | }
|
4130 + | }
|
4131 + | }
|
4132 + | }
|
4133 + | /// See [`TimestampSet`](crate::model::TimestampSet).
|
4134 + | pub mod timestamp_set {
|
4135 + |
|
4136 + | #[allow(clippy::enum_variant_names)]
|
4137 + | #[derive(Debug, PartialEq)]
|
4138 + | 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 + | },
|
4150 + | }
|
4151 + |
|
4152 + | impl ::std::fmt::Display for ConstraintViolation {
|
4153 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4154 + | 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),
|
4157 + | };
|
4158 + | write!(f, "{message}")
|
4159 + | }
|
4160 + | }
|
4161 + |
|
4162 + | impl ::std::error::Error for ConstraintViolation {}
|
4163 + | impl ConstraintViolation {
|
4164 + | pub(crate) fn as_validation_exception_field(
|
4165 + | self,
|
4166 + | path: ::std::string::String,
|
4167 + | ) -> crate::model::ValidationExceptionField {
|
4168 + | 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),
|
4172 + | path,
|
4173 + | },
|
4174 + | }
|
4175 + | }
|
4176 + | }
|
4177 + | }
|
4178 + | /// See [`LongSet`](crate::model::LongSet).
|
4179 + | pub mod long_set {
|
4180 + |
|
4181 + | #[allow(clippy::enum_variant_names)]
|
4182 + | #[derive(Debug, PartialEq)]
|
4183 + | 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 + | },
|
4195 + | }
|
4196 + |
|
4197 + | impl ::std::fmt::Display for ConstraintViolation {
|
4198 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4199 + | 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),
|
4202 + | };
|
4203 + | write!(f, "{message}")
|
4204 + | }
|
4205 + | }
|
4206 + |
|
4207 + | impl ::std::error::Error for ConstraintViolation {}
|
4208 + | impl ConstraintViolation {
|
4209 + | pub(crate) fn as_validation_exception_field(
|
4210 + | self,
|
4211 + | path: ::std::string::String,
|
4212 + | ) -> crate::model::ValidationExceptionField {
|
4213 + | 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),
|
4217 + | path,
|
4218 + | },
|
4219 + | }
|
4220 + | }
|
4221 + | }
|
4222 + | }
|
4223 + | /// See [`IntegerSet`](crate::model::IntegerSet).
|
4224 + | pub mod integer_set {
|
4225 + |
|
4226 + | #[allow(clippy::enum_variant_names)]
|
4227 + | #[derive(Debug, PartialEq)]
|
4228 + | 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 + | },
|
4240 + | }
|
4241 + |
|
4242 + | impl ::std::fmt::Display for ConstraintViolation {
|
4243 + | 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}")
|
4249 + | }
|
4250 + | }
|
4251 + |
|
4252 + | impl ::std::error::Error for ConstraintViolation {}
|
4253 + | impl ConstraintViolation {
|
4254 + | pub(crate) fn as_validation_exception_field(
|
4255 + | self,
|
4256 + | path: ::std::string::String,
|
4257 + | ) -> crate::model::ValidationExceptionField {
|
4258 + | 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),
|
4262 + | path,
|
4263 + | },
|
4264 + | }
|
4265 + | }
|
4266 + | }
|
4267 + | }
|
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 + | },
|
4285 + | }
|
4286 + |
|
4287 + | impl ::std::fmt::Display for ConstraintViolation {
|
4288 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4289 + | 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),
|
4292 + | };
|
4293 + | write!(f, "{message}")
|
4294 + | }
|
4295 + | }
|
4296 + |
|
4297 + | impl ::std::error::Error for ConstraintViolation {}
|
4298 + | impl ConstraintViolation {
|
4299 + | pub(crate) fn as_validation_exception_field(
|
4300 + | self,
|
4301 + | path: ::std::string::String,
|
4302 + | ) -> crate::model::ValidationExceptionField {
|
4303 + | 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,
|
4308 + | },
|
4309 + | }
|
4310 + | }
|
4311 + | }
|
4312 + | }
|
4313 + | /// See [`ByteSet`](crate::model::ByteSet).
|
4314 + | pub mod byte_set {
|
4315 + |
|
4316 + | #[allow(clippy::enum_variant_names)]
|
4317 + | #[derive(Debug, PartialEq)]
|
4318 + | 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 + | },
|
4330 + | }
|
4331 + |
|
4332 + | impl ::std::fmt::Display for ConstraintViolation {
|
4333 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4334 + | 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),
|
4337 + | };
|
4338 + | write!(f, "{message}")
|
4339 + | }
|
4340 + | }
|
4341 + |
|
4342 + | impl ::std::error::Error for ConstraintViolation {}
|
4343 + | impl ConstraintViolation {
|
4344 + | pub(crate) fn as_validation_exception_field(
|
4345 + | self,
|
4346 + | path: ::std::string::String,
|
4347 + | ) -> crate::model::ValidationExceptionField {
|
4348 + | 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,
|
4353 + | },
|
4354 + | }
|
4355 + | }
|
4356 + | }
|
4357 + | }
|
4358 + | /// See [`StringSet`](crate::model::StringSet).
|
4359 + | pub mod string_set {
|
4360 + |
|
4361 + | #[allow(clippy::enum_variant_names)]
|
4362 + | #[derive(Debug, PartialEq)]
|
4363 + | 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 + | },
|
4375 + | }
|
4376 + |
|
4377 + | impl ::std::fmt::Display for ConstraintViolation {
|
4378 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4379 + | 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),
|
4382 + | };
|
4383 + | write!(f, "{message}")
|
4384 + | }
|
4385 + | }
|
4386 + |
|
4387 + | impl ::std::error::Error for ConstraintViolation {}
|
4388 + | impl ConstraintViolation {
|
4389 + | pub(crate) fn as_validation_exception_field(
|
4390 + | self,
|
4391 + | path: ::std::string::String,
|
4392 + | ) -> crate::model::ValidationExceptionField {
|
4393 + | 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 + | },
|
4399 + | }
|
4400 + | }
|
4401 + | }
|
4402 + | }
|
4403 + | /// See [`BooleanSet`](crate::model::BooleanSet).
|
4404 + | pub mod boolean_set {
|
4405 + |
|
4406 + | #[allow(clippy::enum_variant_names)]
|
4407 + | #[derive(Debug, PartialEq)]
|
4408 + | 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 + | },
|
4420 + | }
|
4421 + |
|
4422 + | impl ::std::fmt::Display for ConstraintViolation {
|
4423 + | 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}")
|
4429 + | }
|
4430 + | }
|
4431 + |
|
4432 + | impl ::std::error::Error for ConstraintViolation {}
|
4433 + | impl ConstraintViolation {
|
4434 + | pub(crate) fn as_validation_exception_field(
|
4435 + | self,
|
4436 + | path: ::std::string::String,
|
4437 + | ) -> crate::model::ValidationExceptionField {
|
4438 + | 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 + | },
|
4444 + | }
|
4445 + | }
|
4446 + | }
|
4447 + | }
|
4448 + | /// See [`BlobSet`](crate::model::BlobSet).
|
4449 + | pub mod blob_set {
|
4450 + |
|
4451 + | #[allow(clippy::enum_variant_names)]
|
4452 + | #[derive(Debug, PartialEq)]
|
4453 + | 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 + | },
|
4465 + | }
|
4466 + |
|
4467 + | impl ::std::fmt::Display for ConstraintViolation {
|
4468 + | 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}")
|
4474 + | }
|
4475 + | }
|
4476 + |
|
4477 + | impl ::std::error::Error for ConstraintViolation {}
|
4478 + | impl ConstraintViolation {
|
4479 + | pub(crate) fn as_validation_exception_field(
|
4480 + | self,
|
4481 + | path: ::std::string::String,
|
4482 + | ) -> crate::model::ValidationExceptionField {
|
4483 + | 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 + | },
|
4489 + | }
|
4490 + | }
|
4491 + | }
|
4492 + | }
|
4493 + | /// See [`MaxLong`](crate::model::MaxLong).
|
4494 + | pub mod max_long {
|
4495 + |
|
4496 + | #[derive(Debug, PartialEq)]
|
4497 + | pub enum ConstraintViolation {
|
4498 + | Range(i64),
|
4499 + | }
|
4500 + |
|
4501 + | impl ::std::fmt::Display for ConstraintViolation {
|
4502 + | 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")
|
4504 + | }
|
4505 + | }
|
4506 + |
|
4507 + | impl ::std::error::Error for ConstraintViolation {}
|
4508 + | impl ConstraintViolation {
|
4509 + | pub(crate) fn as_validation_exception_field(
|
4510 + | self,
|
4511 + | path: ::std::string::String,
|
4512 + | ) -> crate::model::ValidationExceptionField {
|
4513 + | 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 + | },
|
4518 + | }
|
4519 + | }
|
4520 + | }
|
4521 + | }
|
4522 + | /// See [`MinLong`](crate::model::MinLong).
|
4523 + | pub mod min_long {
|
4524 + |
|
4525 + | #[derive(Debug, PartialEq)]
|
4526 + | pub enum ConstraintViolation {
|
4527 + | Range(i64),
|
4528 + | }
|
4529 + |
|
4530 + | impl ::std::fmt::Display for ConstraintViolation {
|
4531 + | 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")
|
4533 + | }
|
4534 + | }
|
4535 + |
|
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 + | },
|
4547 + | }
|
4548 + | }
|
4549 + | }
|
4550 + | }
|
4551 + | /// See [`RangeLong`](crate::model::RangeLong).
|
4552 + | pub mod range_long {
|
4553 + |
|
4554 + | #[derive(Debug, PartialEq)]
|
4555 + | pub enum ConstraintViolation {
|
4556 + | Range(i64),
|
4557 + | }
|
4558 + |
|
4559 + | impl ::std::fmt::Display for ConstraintViolation {
|
4560 + | 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")
|
4562 + | }
|
4563 + | }
|
4564 + |
|
4565 + | impl ::std::error::Error for ConstraintViolation {}
|
4566 + | impl ConstraintViolation {
|
4567 + | pub(crate) fn as_validation_exception_field(
|
4568 + | self,
|
4569 + | path: ::std::string::String,
|
4570 + | ) -> crate::model::ValidationExceptionField {
|
4571 + | 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,
|
4575 + | },
|
4576 + | }
|
4577 + | }
|
4578 + | }
|
4579 + | }
|
4580 + | /// See [`MaxInteger`](crate::model::MaxInteger).
|
4581 + | pub mod max_integer {
|
4582 + |
|
4583 + | #[derive(Debug, PartialEq)]
|
4584 + | pub enum ConstraintViolation {
|
4585 + | Range(i32),
|
4586 + | }
|
4587 + |
|
4588 + | impl ::std::fmt::Display for ConstraintViolation {
|
4589 + | 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")
|
4591 + | }
|
4592 + | }
|
4593 + |
|
4594 + | impl ::std::error::Error for ConstraintViolation {}
|
4595 + | impl ConstraintViolation {
|
4596 + | pub(crate) fn as_validation_exception_field(
|
4597 + | self,
|
4598 + | path: ::std::string::String,
|
4599 + | ) -> crate::model::ValidationExceptionField {
|
4600 + | 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 + | },
|
4605 + | }
|
4606 + | }
|
4607 + | }
|
4608 + | }
|
4609 + | /// See [`MinInteger`](crate::model::MinInteger).
|
4610 + | pub mod min_integer {
|
4611 + |
|
4612 + | #[derive(Debug, PartialEq)]
|
4613 + | pub enum ConstraintViolation {
|
4614 + | Range(i32),
|
4615 + | }
|
4616 + |
|
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")
|
4620 + | }
|
4621 + | }
|
4622 + |
|
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 + | }
|
4635 + | }
|
4636 + | }
|
4637 + | }
|
4638 + | /// See [`RangeInteger`](crate::model::RangeInteger).
|
4639 + | pub mod range_integer {
|
4640 + |
|
4641 + | #[derive(Debug, PartialEq)]
|
4642 + | pub enum ConstraintViolation {
|
4643 + | Range(i32),
|
4644 + | }
|
4645 + |
|
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")
|
4649 + | }
|
4650 + | }
|
4651 + |
|
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 + | },
|
4663 + | }
|
4664 + | }
|
4665 + | }
|
4666 + | }
|
4667 + | /// See [`MaxShort`](crate::model::MaxShort).
|
4668 + | pub mod max_short {
|
4669 + |
|
4670 + | #[derive(Debug, PartialEq)]
|
4671 + | pub enum ConstraintViolation {
|
4672 + | Range(i16),
|
4673 + | }
|
4674 + |
|
4675 + | impl ::std::fmt::Display for ConstraintViolation {
|
4676 + | 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")
|
4678 + | }
|
4679 + | }
|
4680 + |
|
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 + | },
|
4692 + | }
|
4693 + | }
|
4694 + | }
|
4695 + | }
|
4696 + | /// See [`MinShort`](crate::model::MinShort).
|
4697 + | pub mod min_short {
|
4698 + |
|
4699 + | #[derive(Debug, PartialEq)]
|
4700 + | pub enum ConstraintViolation {
|
4701 + | Range(i16),
|
4702 + | }
|
4703 + |
|
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")
|
4707 + | }
|
4708 + | }
|
4709 + |
|
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 + | }
|
4722 + | }
|
4723 + | }
|
4724 + | }
|
4725 + | /// See [`RangeShort`](crate::model::RangeShort).
|
4726 + | pub mod range_short {
|
4727 + |
|
4728 + | #[derive(Debug, PartialEq)]
|
4729 + | pub enum ConstraintViolation {
|
4730 + | Range(i16),
|
4731 + | }
|
4732 + |
|
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")
|
4736 + | }
|
4737 + | }
|
4738 + |
|
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 + | },
|
4750 + | }
|
4751 + | }
|
4752 + | }
|
4753 + | }
|
4754 + | /// See [`MaxByte`](crate::model::MaxByte).
|
4755 + | pub mod max_byte {
|
4756 + |
|
4757 + | #[derive(Debug, PartialEq)]
|
4758 + | pub enum ConstraintViolation {
|
4759 + | Range(i8),
|
4760 + | }
|
4761 + |
|
4762 + | impl ::std::fmt::Display for ConstraintViolation {
|
4763 + | 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")
|
4765 + | }
|
4766 + | }
|
4767 + |
|
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 + | },
|
4779 + | }
|
4780 + | }
|
4781 + | }
|
4782 + | }
|
4783 + | /// See [`MinByte`](crate::model::MinByte).
|
4784 + | pub mod min_byte {
|
4785 + |
|
4786 + | #[derive(Debug, PartialEq)]
|
4787 + | pub enum ConstraintViolation {
|
4788 + | Range(i8),
|
4789 + | }
|
4790 + |
|
4791 + | impl ::std::fmt::Display for ConstraintViolation {
|
4792 + | 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")
|
4794 + | }
|
4795 + | }
|
4796 + |
|
4797 + | impl ::std::error::Error for ConstraintViolation {}
|
4798 + | impl ConstraintViolation {
|
4799 + | pub(crate) fn as_validation_exception_field(
|
4800 + | self,
|
4801 + | path: ::std::string::String,
|
4802 + | ) -> crate::model::ValidationExceptionField {
|
4803 + | 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,
|
4807 + | },
|
4808 + | }
|
4809 + | }
|
4810 + | }
|
4811 + | }
|
4812 + | /// See [`RangeByte`](crate::model::RangeByte).
|
4813 + | pub mod range_byte {
|
4814 + |
|
4815 + | #[derive(Debug, PartialEq)]
|
4816 + | pub enum ConstraintViolation {
|
4817 + | Range(i8),
|
4818 + | }
|
4819 + |
|
4820 + | impl ::std::fmt::Display for ConstraintViolation {
|
4821 + | 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")
|
4823 + | }
|
4824 + | }
|
4825 + |
|
4826 + | impl ::std::error::Error for ConstraintViolation {}
|
4827 + | impl ConstraintViolation {
|
4828 + | pub(crate) fn as_validation_exception_field(
|
4829 + | self,
|
4830 + | path: ::std::string::String,
|
4831 + | ) -> crate::model::ValidationExceptionField {
|
4832 + | 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,
|
4836 + | },
|
4837 + | }
|
4838 + | }
|
4839 + | }
|
4840 + | }
|
4841 + | pub mod pattern_union_override {
|
4842 + |
|
4843 + | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
4844 + | #[allow(clippy::enum_variant_names)]
|
4845 + | pub enum ConstraintViolation {
|
4846 + | First(crate::model::pattern_union_override::first::ConstraintViolation),
|
4847 + | Second(crate::model::pattern_union_override::second::ConstraintViolation),
|
4848 + | }
|
4849 + | impl ::std::fmt::Display for ConstraintViolation {
|
4850 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4851 + | match self {
|
4852 + | Self::First(inner) => write!(f, "{inner}"),
|
4853 + | Self::Second(inner) => write!(f, "{inner}"),
|
4854 + | }
|
4855 + | }
|
4856 + | }
|
4857 + |
|
4858 + | impl ::std::error::Error for ConstraintViolation {}
|
4859 + | impl ConstraintViolation {
|
4860 + | pub(crate) fn as_validation_exception_field(
|
4861 + | self,
|
4862 + | path: ::std::string::String,
|
4863 + | ) -> crate::model::ValidationExceptionField {
|
4864 + | match self {
|
4865 + | Self::First(inner) => inner.as_validation_exception_field(path + "/first"),
|
4866 + | Self::Second(inner) => inner.as_validation_exception_field(path + "/second"),
|
4867 + | }
|
4868 + | }
|
4869 + | }
|
4870 + | #[allow(missing_docs)] // documentation missing in model
|
4871 + | ///
|
4872 + | /// This is a constrained type because its corresponding modeled Smithy shape has one or more
|
4873 + | /// [constraint traits]. Use [`Second::try_from`] to construct values of this type.
|
4874 + | ///
|
4875 + | /// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
|
4876 + | ///
|
4877 + | #[derive(
|
4878 + | ::std::clone::Clone,
|
4879 + | ::std::cmp::Eq,
|
4880 + | ::std::cmp::PartialEq,
|
4881 + | ::std::fmt::Debug,
|
4882 + | ::std::hash::Hash,
|
4883 + | )]
|
4884 + | pub struct Second(pub(crate) ::std::string::String);
|
4885 + | impl Second {
|
4886 + | /// Extracts a string slice containing the entire underlying `String`.
|
4887 + | pub fn as_str(&self) -> &str {
|
4888 + | &self.0
|
4889 + | }
|
4890 + |
|
4891 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
4892 + | pub fn inner(&self) -> &::std::string::String {
|
4893 + | &self.0
|
4894 + | }
|
4895 + |
|
4896 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
4897 + | pub fn into_inner(self) -> ::std::string::String {
|
4898 + | self.0
|
4899 + | }
|
4900 + | }
|
4901 + | impl Second {
|
4902 + | fn check_pattern(
|
4903 + | string: ::std::string::String,
|
4904 + | ) -> ::std::result::Result<
|
4905 + | ::std::string::String,
|
4906 + | crate::model::pattern_union_override::second::ConstraintViolation,
|
4907 + | > {
|
4908 + | let regex = Self::compile_regex();
|
4909 + |
|
4910 + | if regex.is_match(&string) {
|
4911 + | Ok(string)
|
4912 + | } else {
|
4913 + | Err(
|
4914 + | crate::model::pattern_union_override::second::ConstraintViolation::Pattern(
|
4915 + | string,
|
4916 + | ),
|
4917 + | )
|
4918 + | }
|
4919 + | }
|
4920 + |
|
4921 + | /// Attempts to compile the regex for this constrained type's `@pattern`.
|
4922 + | /// This can fail if the specified regex is not supported by the `::regex` crate.
|
4923 + | pub fn compile_regex() -> &'static ::regex::Regex {
|
4924 + | static REGEX: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| {
|
4925 + | ::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"#)
|
4926 + | });
|
4927 + |
|
4928 + | ®EX
|
4929 + | }
|
4930 + | }
|
4931 + | impl ::std::convert::TryFrom<::std::string::String> for Second {
|
4932 + | type Error = crate::model::pattern_union_override::second::ConstraintViolation;
|
4933 + |
|
4934 + | /// Constructs a `Second` from an [`::std::string::String`], failing when the provided value does not satisfy the modeled constraints.
|
4935 + | fn try_from(value: ::std::string::String) -> ::std::result::Result<Self, Self::Error> {
|
4936 + | let value = Self::check_pattern(value)?;
|
4937 + |
|
4938 + | Ok(Self(value))
|
4939 + | }
|
4940 + | }
|
4941 + | impl crate::constrained::Constrained for Second {
|
4942 + | type Unconstrained = ::std::string::String;
|
4943 + | }
|
4944 + |
|
4945 + | impl ::std::convert::From<::std::string::String>
|
4946 + | for crate::constrained::MaybeConstrained<crate::model::pattern_union_override::Second>
|
4947 + | {
|
4948 + | fn from(value: ::std::string::String) -> Self {
|
4949 + | Self::Unconstrained(value)
|
4950 + | }
|
4951 + | }
|
4952 + |
|
4953 + | impl ::std::fmt::Display for Second {
|
4954 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
4955 + | self.0.fmt(f)
|
4956 + | }
|
4957 + | }
|
4958 + |
|
4959 + | impl ::std::convert::From<Second> for ::std::string::String {
|
4960 + | fn from(value: Second) -> Self {
|
4961 + | value.into_inner()
|
4962 + | }
|
4963 + | }
|
4964 + | #[cfg(test)]
|
4965 + | mod test_second {
|
4966 + | #[test]
|
4967 + | fn regex_compiles() {
|
4968 + | crate::model::pattern_union_override::Second::compile_regex();
|
4969 + | }
|
4970 + | }
|
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
|
4990 + | }
|
4991 + |
|
4992 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
4993 + | pub fn inner(&self) -> &::std::string::String {
|
4994 + | &self.0
|
4995 + | }
|
4996 + |
|
4997 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
4998 + | pub fn into_inner(self) -> ::std::string::String {
|
4999 + | self.0
|
5000 + | }
|
5001 + | }
|
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();
|
5010 + |
|
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 + | ),
|
5018 + | )
|
5019 + | }
|
5020 + | }
|
5021 + |
|
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 + | });
|
5028 + |
|
5029 + | ®EX
|
5030 + | }
|
5031 + | }
|
5032 + | impl ::std::convert::TryFrom<::std::string::String> for First {
|
5033 + | type Error = crate::model::pattern_union_override::first::ConstraintViolation;
|
5034 + |
|
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)?;
|
5038 + |
|
5039 + | Ok(Self(value))
|
5040 + | }
|
5041 + | }
|
5042 + | impl crate::constrained::Constrained for First {
|
5043 + | type Unconstrained = ::std::string::String;
|
5044 + | }
|
5045 + |
|
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)
|
5051 + | }
|
5052 + | }
|
5053 + |
|
5054 + | impl ::std::fmt::Display for First {
|
5055 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5056 + | self.0.fmt(f)
|
5057 + | }
|
5058 + | }
|
5059 + |
|
5060 + | impl ::std::convert::From<First> for ::std::string::String {
|
5061 + | fn from(value: First) -> Self {
|
5062 + | value.into_inner()
|
5063 + | }
|
5064 + | }
|
5065 + | #[cfg(test)]
|
5066 + | mod test_first {
|
5067 + | #[test]
|
5068 + | fn regex_compiles() {
|
5069 + | crate::model::pattern_union_override::First::compile_regex();
|
5070 + | }
|
5071 + | }
|
5072 + |
|
5073 + | /// See [`PatternUnionOverrideSecond`](crate::model::pattern_union_override::Second).
|
5074 + | pub mod second {
|
5075 + |
|
5076 + | #[derive(Debug, PartialEq)]
|
5077 + | pub enum ConstraintViolation {
|
5078 + | /// Error when a string doesn't satisfy its `@pattern`.
|
5079 + | /// Contains the String that failed the pattern.
|
5080 + | Pattern(String),
|
5081 + | }
|
5082 + |
|
5083 + | impl ::std::fmt::Display for ConstraintViolation {
|
5084 + | 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}")
|
5094 + | }
|
5095 + | }
|
5096 + |
|
5097 + | impl ::std::error::Error for ConstraintViolation {}
|
5098 + | impl ConstraintViolation {
|
5099 + | pub(crate) fn as_validation_exception_field(
|
5100 + | self,
|
5101 + | path: ::std::string::String,
|
5102 + | ) -> crate::model::ValidationExceptionField {
|
5103 + | 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
|
5108 + | },
|
5109 + | }
|
5110 + | }
|
5111 + | }
|
5112 + | }
|
5113 + | /// See [`PatternUnionOverrideFirst`](crate::model::pattern_union_override::First).
|
5114 + | pub mod first {
|
5115 + |
|
5116 + | #[derive(Debug, PartialEq)]
|
5117 + | pub enum ConstraintViolation {
|
5118 + | /// Error when a string doesn't satisfy its `@pattern`.
|
5119 + | /// Contains the String that failed the pattern.
|
5120 + | Pattern(String),
|
5121 + | }
|
5122 + |
|
5123 + | impl ::std::fmt::Display for ConstraintViolation {
|
5124 + | 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}")
|
5134 + | }
|
5135 + | }
|
5136 + |
|
5137 + | impl ::std::error::Error for ConstraintViolation {}
|
5138 + | impl ConstraintViolation {
|
5139 + | pub(crate) fn as_validation_exception_field(
|
5140 + | self,
|
5141 + | path: ::std::string::String,
|
5142 + | ) -> crate::model::ValidationExceptionField {
|
5143 + | 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
|
5148 + | },
|
5149 + | }
|
5150 + | }
|
5151 + | }
|
5152 + | }
|
5153 + | }
|
5154 + | pub mod pattern_map_override {
|
5155 + |
|
5156 + | #[allow(clippy::enum_variant_names)]
|
5157 + | #[derive(Debug, PartialEq)]
|
5158 + | 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 + | ),
|
5166 + | }
|
5167 + |
|
5168 + | impl ::std::fmt::Display for ConstraintViolation {
|
5169 + | 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 + | }
|
5176 + | }
|
5177 + | }
|
5178 + |
|
5179 + | impl ::std::error::Error for ConstraintViolation {}
|
5180 + | impl ConstraintViolation {
|
5181 + | pub(crate) fn as_validation_exception_field(
|
5182 + | self,
|
5183 + | path: ::std::string::String,
|
5184 + | ) -> crate::model::ValidationExceptionField {
|
5185 + | 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 + | }
|
5192 + | }
|
5193 + | }
|
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 + | }
|
5214 + |
|
5215 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
5216 + | pub fn inner(&self) -> &::std::string::String {
|
5217 + | &self.0
|
5218 + | }
|
5219 + |
|
5220 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
5221 + | pub fn into_inner(self) -> ::std::string::String {
|
5222 + | self.0
|
5223 + | }
|
5224 + | }
|
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 + |
|
5234 + | if regex.is_match(&string) {
|
5235 + | Ok(string)
|
5236 + | } else {
|
5237 + | Err(crate::model::pattern_map_override::value::ConstraintViolation::Pattern(string))
|
5238 + | }
|
5239 + | }
|
5240 + |
|
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 + | });
|
5247 + |
|
5248 + | ®EX
|
5249 + | }
|
5250 + | }
|
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 + |
|
5258 + | Ok(Self(value))
|
5259 + | }
|
5260 + | }
|
5261 + | impl crate::constrained::Constrained for Value {
|
5262 + | type Unconstrained = ::std::string::String;
|
5263 + | }
|
5264 + |
|
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 + | }
|
5271 + | }
|
5272 + |
|
5273 + | impl ::std::fmt::Display for Value {
|
5274 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5275 + | self.0.fmt(f)
|
5276 + | }
|
5277 + | }
|
5278 + |
|
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
|
5310 + | }
|
5311 + |
|
5312 + | /// Returns an immutable reference to the underlying [`::std::string::String`].
|
5313 + | pub fn inner(&self) -> &::std::string::String {
|
5314 + | &self.0
|
5315 + | }
|
5316 + |
|
5317 + | /// Consumes the value, returning the underlying [`::std::string::String`].
|
5318 + | pub fn into_inner(self) -> ::std::string::String {
|
5319 + | self.0
|
5320 + | }
|
5321 + | }
|
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 + |
|
5331 + | if regex.is_match(&string) {
|
5332 + | Ok(string)
|
5333 + | } else {
|
5334 + | Err(crate::model::pattern_map_override::key::ConstraintViolation::Pattern(string))
|
5335 + | }
|
5336 + | }
|
5337 + |
|
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 + | });
|
5344 + |
|
5345 + | ®EX
|
5346 + | }
|
5347 + | }
|
5348 + | impl ::std::convert::TryFrom<::std::string::String> for Key {
|
5349 + | type Error = crate::model::pattern_map_override::key::ConstraintViolation;
|
5350 + |
|
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))
|
5356 + | }
|
5357 + | }
|
5358 + | impl crate::constrained::Constrained for Key {
|
5359 + | type Unconstrained = ::std::string::String;
|
5360 + | }
|
5361 + |
|
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 + | }
|
5368 + | }
|
5369 + |
|
5370 + | impl ::std::fmt::Display for Key {
|
5371 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5372 + | self.0.fmt(f)
|
5373 + | }
|
5374 + | }
|
5375 + |
|
5376 + | impl ::std::convert::From<Key> for ::std::string::String {
|
5377 + | fn from(value: Key) -> Self {
|
5378 + | value.into_inner()
|
5379 + | }
|
5380 + | }
|
5381 + | #[cfg(test)]
|
5382 + | mod test_key {
|
5383 + | #[test]
|
5384 + | fn regex_compiles() {
|
5385 + | crate::model::pattern_map_override::Key::compile_regex();
|
5386 + | }
|
5387 + | }
|
5388 + |
|
5389 + | /// See [`PatternMapOverrideValue`](crate::model::pattern_map_override::Value).
|
5390 + | pub mod value {
|
5391 + |
|
5392 + | #[derive(Debug, PartialEq)]
|
5393 + | pub enum ConstraintViolation {
|
5394 + | /// Error when a string doesn't satisfy its `@pattern`.
|
5395 + | /// Contains the String that failed the pattern.
|
5396 + | Pattern(String),
|
5397 + | }
|
5398 + |
|
5399 + | impl ::std::fmt::Display for ConstraintViolation {
|
5400 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5401 + | 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 + | }
|
5408 + | };
|
5409 + | write!(f, "{message}")
|
5410 + | }
|
5411 + | }
|
5412 + |
|
5413 + | impl ::std::error::Error for ConstraintViolation {}
|
5414 + | impl ConstraintViolation {
|
5415 + | pub(crate) fn as_validation_exception_field(
|
5416 + | self,
|
5417 + | path: ::std::string::String,
|
5418 + | ) -> crate::model::ValidationExceptionField {
|
5419 + | 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
|
5424 + | },
|
5425 + | }
|
5426 + | }
|
5427 + | }
|
5428 + | }
|
5429 + | /// See [`PatternMapOverrideKey`](crate::model::pattern_map_override::Key).
|
5430 + | pub mod key {
|
5431 + |
|
5432 + | #[derive(Debug, PartialEq)]
|
5433 + | pub enum ConstraintViolation {
|
5434 + | /// Error when a string doesn't satisfy its `@pattern`.
|
5435 + | /// Contains the String that failed the pattern.
|
5436 + | Pattern(String),
|
5437 + | }
|
5438 + |
|
5439 + | impl ::std::fmt::Display for ConstraintViolation {
|
5440 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5441 + | 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 + | )
|
5447 + | }
|
5448 + | };
|
5449 + | write!(f, "{message}")
|
5450 + | }
|
5451 + | }
|
5452 + |
|
5453 + | impl ::std::error::Error for ConstraintViolation {}
|
5454 + | impl ConstraintViolation {
|
5455 + | pub(crate) fn as_validation_exception_field(
|
5456 + | self,
|
5457 + | path: ::std::string::String,
|
5458 + | ) -> crate::model::ValidationExceptionField {
|
5459 + | 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
|
5464 + | },
|
5465 + | }
|
5466 + | }
|
5467 + | }
|
5468 + | }
|
5469 + | }
|
5470 + | pub mod pattern_list_override {
|
5471 + |
|
5472 + | #[allow(clippy::enum_variant_names)]
|
5473 + | #[derive(Debug, PartialEq)]
|
5474 + | 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 + | ),
|
5483 + | }
|
5484 + |
|
5485 + | impl ::std::fmt::Display for ConstraintViolation {
|
5486 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5487 + | let message = match self {
|
5488 + | Self::Member(index, failing_member) => format!(
|
5489 + | "Value at index {index} failed to satisfy constraint. {}",
|
5490 + | failing_member
|
5491 + | ),
|
5492 + | };
|
5493 + | write!(f, "{message}")
|
5494 + | }
|
5495 + | }
|
5496 + |
|
5497 + | impl ::std::error::Error for ConstraintViolation {}
|
5498 + | impl ConstraintViolation {
|
5499 + | pub(crate) fn as_validation_exception_field(
|
5500 + | self,
|
5501 + | path: ::std::string::String,
|
5502 + | ) -> crate::model::ValidationExceptionField {
|
5503 + | 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 + | }
|
5602 + | }
|
5603 + | #[cfg(test)]
|
5604 + | mod test_member {
|
5605 + | #[test]
|
5606 + | fn regex_compiles() {
|
5607 + | crate::model::pattern_list_override::Member::compile_regex();
|
5608 + | }
|
5609 + | }
|
5610 + |
|
5611 + | /// See [`PatternListOverrideMember`](crate::model::pattern_list_override::Member).
|
5612 + | pub mod member {
|
5613 + |
|
5614 + | #[derive(Debug, PartialEq)]
|
5615 + | pub enum ConstraintViolation {
|
5616 + | /// Error when a string doesn't satisfy its `@pattern`.
|
5617 + | /// Contains the String that failed the pattern.
|
5618 + | Pattern(String),
|
5619 + | }
|
5620 + |
|
5621 + | impl ::std::fmt::Display for ConstraintViolation {
|
5622 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5623 + | 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 + | }
|
5630 + | };
|
5631 + | write!(f, "{message}")
|
5632 + | }
|
5633 + | }
|
5634 + |
|
5635 + | impl ::std::error::Error for ConstraintViolation {}
|
5636 + | impl ConstraintViolation {
|
5637 + | pub(crate) fn as_validation_exception_field(
|
5638 + | self,
|
5639 + | path: ::std::string::String,
|
5640 + | ) -> crate::model::ValidationExceptionField {
|
5641 + | 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
|
5646 + | },
|
5647 + | }
|
5648 + | }
|
5649 + | }
|
5650 + | }
|
5651 + | }
|
5652 + | pub mod pattern_union {
|
5653 + |
|
5654 + | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
5655 + | #[allow(clippy::enum_variant_names)]
|
5656 + | pub enum ConstraintViolation {
|
5657 + | First(crate::model::pattern_string::ConstraintViolation),
|
5658 + | Second(crate::model::pattern_string::ConstraintViolation),
|
5659 + | }
|
5660 + | impl ::std::fmt::Display for ConstraintViolation {
|
5661 + | 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 + | }
|
5666 + | }
|
5667 + | }
|
5668 + |
|
5669 + | impl ::std::error::Error for ConstraintViolation {}
|
5670 + | impl ConstraintViolation {
|
5671 + | pub(crate) fn as_validation_exception_field(
|
5672 + | self,
|
5673 + | path: ::std::string::String,
|
5674 + | ) -> crate::model::ValidationExceptionField {
|
5675 + | match self {
|
5676 + | Self::First(inner) => inner.as_validation_exception_field(path + "/first"),
|
5677 + | Self::Second(inner) => inner.as_validation_exception_field(path + "/second"),
|
5678 + | }
|
5679 + | }
|
5680 + | }
|
5681 + | }
|
5682 + | /// See [`PatternString`](crate::model::PatternString).
|
5683 + | pub mod pattern_string {
|
5684 + |
|
5685 + | #[derive(Debug, PartialEq)]
|
5686 + | pub enum ConstraintViolation {
|
5687 + | /// Error when a string doesn't satisfy its `@pattern`.
|
5688 + | /// Contains the String that failed the pattern.
|
5689 + | Pattern(String),
|
5690 + | }
|
5691 + |
|
5692 + | impl ::std::fmt::Display for ConstraintViolation {
|
5693 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5694 + | 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 + | }
|
5701 + | };
|
5702 + | write!(f, "{message}")
|
5703 + | }
|
5704 + | }
|
5705 + |
|
5706 + | impl ::std::error::Error for ConstraintViolation {}
|
5707 + | impl ConstraintViolation {
|
5708 + | pub(crate) fn as_validation_exception_field(
|
5709 + | self,
|
5710 + | path: ::std::string::String,
|
5711 + | ) -> crate::model::ValidationExceptionField {
|
5712 + | 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
|
5717 + | },
|
5718 + | }
|
5719 + | }
|
5720 + | }
|
5721 + | }
|
5722 + | pub mod pattern_map {
|
5723 + |
|
5724 + | #[allow(clippy::enum_variant_names)]
|
5725 + | #[derive(Debug, PartialEq)]
|
5726 + | 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 + | ),
|
5734 + | }
|
5735 + |
|
5736 + | impl ::std::fmt::Display for ConstraintViolation {
|
5737 + | 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 + | }
|
5744 + | }
|
5745 + | }
|
5746 + |
|
5747 + | impl ::std::error::Error for ConstraintViolation {}
|
5748 + | impl ConstraintViolation {
|
5749 + | pub(crate) fn as_validation_exception_field(
|
5750 + | self,
|
5751 + | path: ::std::string::String,
|
5752 + | ) -> crate::model::ValidationExceptionField {
|
5753 + | 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()),
|
5759 + | }
|
5760 + | }
|
5761 + | }
|
5762 + | }
|
5763 + | pub mod pattern_list {
|
5764 + |
|
5765 + | #[allow(clippy::enum_variant_names)]
|
5766 + | #[derive(Debug, PartialEq)]
|
5767 + | pub enum ConstraintViolation {
|
5768 + | /// Constraint violation error when an element doesn't satisfy its own constraints.
|
5769 + | /// The first component of the tuple is the index in the collection where the
|
5770 + | /// first constraint violation was found.
|
5771 + | #[doc(hidden)]
|
5772 + | Member(usize, crate::model::pattern_string::ConstraintViolation),
|
5773 + | }
|
5774 + |
|
5775 + | impl ::std::fmt::Display for ConstraintViolation {
|
5776 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5777 + | let message = match self {
|
5778 + | Self::Member(index, failing_member) => format!(
|
5779 + | "Value at index {index} failed to satisfy constraint. {}",
|
5780 + | failing_member
|
5781 + | ),
|
5782 + | };
|
5783 + | write!(f, "{message}")
|
5784 + | }
|
5785 + | }
|
5786 + |
|
5787 + | impl ::std::error::Error for ConstraintViolation {}
|
5788 + | impl ConstraintViolation {
|
5789 + | pub(crate) fn as_validation_exception_field(
|
5790 + | self,
|
5791 + | path: ::std::string::String,
|
5792 + | ) -> crate::model::ValidationExceptionField {
|
5793 + | match self {
|
5794 + | Self::Member(index, member_constraint_violation) => member_constraint_violation
|
5795 + | .as_validation_exception_field(path + "/" + &index.to_string()),
|
5796 + | }
|
5797 + | }
|
5798 + | }
|
5799 + | }
|
5800 + | /// See [`EvilString`](crate::model::EvilString).
|
5801 + | pub mod evil_string {
|
5802 + |
|
5803 + | #[derive(Debug, PartialEq)]
|
5804 + | pub enum ConstraintViolation {
|
5805 + | /// Error when a string doesn't satisfy its `@pattern`.
|
5806 + | /// Contains the String that failed the pattern.
|
5807 + | Pattern(String),
|
5808 + | }
|
5809 + |
|
5810 + | impl ::std::fmt::Display for ConstraintViolation {
|
5811 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5812 + | 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 + | }
|
5819 + | };
|
5820 + | write!(f, "{message}")
|
5821 + | }
|
5822 + | }
|
5823 + |
|
5824 + | impl ::std::error::Error for ConstraintViolation {}
|
5825 + | impl ConstraintViolation {
|
5826 + | pub(crate) fn as_validation_exception_field(
|
5827 + | self,
|
5828 + | path: ::std::string::String,
|
5829 + | ) -> crate::model::ValidationExceptionField {
|
5830 + | 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
|
5835 + | },
|
5836 + | }
|
5837 + | }
|
5838 + | }
|
5839 + | }
|
5840 + | /// See [`LengthString`](crate::model::LengthString).
|
5841 + | pub mod length_string {
|
5842 + |
|
5843 + | #[derive(Debug, PartialEq)]
|
5844 + | pub enum ConstraintViolation {
|
5845 + | /// Error when a string doesn't satisfy its `@length` requirements.
|
5846 + | Length(usize),
|
5847 + | }
|
5848 + |
|
5849 + | impl ::std::fmt::Display for ConstraintViolation {
|
5850 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5851 + | 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 + | }
|
5855 + | };
|
5856 + | write!(f, "{message}")
|
5857 + | }
|
5858 + | }
|
5859 + |
|
5860 + | impl ::std::error::Error for ConstraintViolation {}
|
5861 + | impl ConstraintViolation {
|
5862 + | pub(crate) fn as_validation_exception_field(
|
5863 + | self,
|
5864 + | path: ::std::string::String,
|
5865 + | ) -> crate::model::ValidationExceptionField {
|
5866 + | 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),
|
5869 + | path,
|
5870 + | },
|
5871 + | }
|
5872 + | }
|
5873 + | }
|
5874 + | }
|
5875 + | /// See [`LengthList`](crate::model::LengthList).
|
5876 + | pub mod length_list {
|
5877 + |
|
5878 + | #[allow(clippy::enum_variant_names)]
|
5879 + | #[derive(Debug, PartialEq)]
|
5880 + | 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),
|
5888 + | }
|
5889 + |
|
5890 + | impl ::std::fmt::Display for ConstraintViolation {
|
5891 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5892 + | 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 + | ),
|
5900 + | };
|
5901 + | write!(f, "{message}")
|
5902 + | }
|
5903 + | }
|
5904 + |
|
5905 + | impl ::std::error::Error for ConstraintViolation {}
|
5906 + | impl ConstraintViolation {
|
5907 + | pub(crate) fn as_validation_exception_field(
|
5908 + | self,
|
5909 + | path: ::std::string::String,
|
5910 + | ) -> crate::model::ValidationExceptionField {
|
5911 + | 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),
|
5914 + | path,
|
5915 + | },
|
5916 + | Self::Member(index, member_constraint_violation) =>
|
5917 + | member_constraint_violation.as_validation_exception_field(path + "/" + &index.to_string())
|
5918 + | }
|
5919 + | }
|
5920 + | }
|
5921 + | }
|
5922 + | /// See [`LengthMap`](crate::model::LengthMap).
|
5923 + | pub mod length_map {
|
5924 + |
|
5925 + | #[allow(clippy::enum_variant_names)]
|
5926 + | #[derive(Debug, PartialEq)]
|
5927 + | pub enum ConstraintViolation {
|
5928 + | Length(usize),
|
5929 + | #[doc(hidden)]
|
5930 + | Key(crate::model::length_string::ConstraintViolation),
|
5931 + | #[doc(hidden)]
|
5932 + | Value(
|
5933 + | crate::model::LengthString,
|
5934 + | crate::model::length_list::ConstraintViolation,
|
5935 + | ),
|
5936 + | }
|
5937 + |
|
5938 + | impl ::std::fmt::Display for ConstraintViolation {
|
5939 + | 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 + | }
|
5949 + | }
|
5950 + | }
|
5951 + |
|
5952 + | impl ::std::error::Error for ConstraintViolation {}
|
5953 + | impl ConstraintViolation {
|
5954 + | pub(crate) fn as_validation_exception_field(
|
5955 + | self,
|
5956 + | path: ::std::string::String,
|
5957 + | ) -> crate::model::ValidationExceptionField {
|
5958 + | 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),
|
5961 + | path,
|
5962 + | },
|
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()),
|
5965 + | }
|
5966 + | }
|
5967 + | }
|
5968 + | }
|
5969 + | /// See [`MaxLengthString`](crate::model::MaxLengthString).
|
5970 + | pub mod max_length_string {
|
5971 + |
|
5972 + | #[derive(Debug, PartialEq)]
|
5973 + | pub enum ConstraintViolation {
|
5974 + | /// Error when a string doesn't satisfy its `@length` requirements.
|
5975 + | Length(usize),
|
5976 + | }
|
5977 + |
|
5978 + | impl ::std::fmt::Display for ConstraintViolation {
|
5979 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
5980 + | 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 + | }
|
5984 + | };
|
5985 + | write!(f, "{message}")
|
5986 + | }
|
5987 + | }
|
5988 + |
|
5989 + | impl ::std::error::Error for ConstraintViolation {}
|
5990 + | impl ConstraintViolation {
|
5991 + | pub(crate) fn as_validation_exception_field(
|
5992 + | self,
|
5993 + | path: ::std::string::String,
|
5994 + | ) -> crate::model::ValidationExceptionField {
|
5995 + | 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),
|
5998 + | path,
|
5999 + | },
|
6000 + | }
|
6001 + | }
|
6002 + | }
|
6003 + | }
|
6004 + | /// See [`MinLengthString`](crate::model::MinLengthString).
|
6005 + | pub mod min_length_string {
|
6006 + |
|
6007 + | #[derive(Debug, PartialEq)]
|
6008 + | pub enum ConstraintViolation {
|
6009 + | /// Error when a string doesn't satisfy its `@length` requirements.
|
6010 + | Length(usize),
|
6011 + | }
|
6012 + |
|
6013 + | impl ::std::fmt::Display for ConstraintViolation {
|
6014 + | 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)
|
6018 + | }
|
6019 + | };
|
6020 + | write!(f, "{message}")
|
6021 + | }
|
6022 + | }
|
6023 + |
|
6024 + | impl ::std::error::Error for ConstraintViolation {}
|
6025 + | impl ConstraintViolation {
|
6026 + | pub(crate) fn as_validation_exception_field(
|
6027 + | self,
|
6028 + | path: ::std::string::String,
|
6029 + | ) -> crate::model::ValidationExceptionField {
|
6030 + | 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 + | },
|
6035 + | }
|
6036 + | }
|
6037 + | }
|
6038 + | }
|
6039 + | /// See [`LengthBlob`](crate::model::LengthBlob).
|
6040 + | pub mod length_blob {
|
6041 + |
|
6042 + | #[derive(Debug, PartialEq)]
|
6043 + | pub enum ConstraintViolation {
|
6044 + | /// Error when a blob doesn't satisfy its `@length` requirements.
|
6045 + | Length(usize),
|
6046 + | }
|
6047 + |
|
6048 + | impl ::std::fmt::Display for ConstraintViolation {
|
6049 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
6050 + | 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)
|
6053 + | }
|
6054 + | };
|
6055 + | write!(f, "{message}")
|
6056 + | }
|
6057 + | }
|
6058 + |
|
6059 + | impl ::std::error::Error for ConstraintViolation {}
|
6060 + | impl ConstraintViolation {
|
6061 + | pub(crate) fn as_validation_exception_field(
|
6062 + | self,
|
6063 + | path: ::std::string::String,
|
6064 + | ) -> crate::model::ValidationExceptionField {
|
6065 + | 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,
|
6069 + | },
|
6070 + | }
|
6071 + | }
|
6072 + | }
|
6073 + | }
|
6074 + | pub mod enum_union {
|
6075 + |
|
6076 + | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
6077 + | #[allow(clippy::enum_variant_names)]
|
6078 + | pub enum ConstraintViolation {
|
6079 + | First(crate::model::enum_string::ConstraintViolation),
|
6080 + | Second(crate::model::enum_string::ConstraintViolation),
|
6081 + | }
|
6082 + | impl ::std::fmt::Display for ConstraintViolation {
|
6083 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
6084 + | match self {
|
6085 + | Self::First(inner) => write!(f, "{inner}"),
|
6086 + | Self::Second(inner) => write!(f, "{inner}"),
|
6087 + | }
|
6088 + | }
|
6089 + | }
|
6090 + |
|
6091 + | impl ::std::error::Error for ConstraintViolation {}
|
6092 + | impl ConstraintViolation {
|
6093 + | pub(crate) fn as_validation_exception_field(
|
6094 + | 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"),
|
6100 + | }
|
6101 + | }
|
6102 + | }
|
6103 + | }
|
6104 + | pub mod enum_map {
|
6105 + |
|
6106 + | #[allow(clippy::enum_variant_names)]
|
6107 + | #[derive(Debug, PartialEq)]
|
6108 + | 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 + | ),
|
6116 + | }
|
6117 + |
|
6118 + | impl ::std::fmt::Display for ConstraintViolation {
|
6119 + | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
6120 + | 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 + | }
|
6125 + | }
|
6126 + | }
|
6127 + | }
|
6128 + |
|
6129 + | impl ::std::error::Error for ConstraintViolation {}
|
6130 + | impl ConstraintViolation {
|
6131 + | pub(crate) fn as_validation_exception_field(
|
6132 + | self,
|
6133 + | path: ::std::string::String,
|
6134 + | ) -> crate::model::ValidationExceptionField {
|
6135 + | match self {
|
6136 + | Self::Key(key_constraint_violation) => {
|
6137 + | key_constraint_violation.as_validation_exception_field(path)
|
6138 + | }
|
6139 + | Self::Value(key, value_constraint_violation) => value_constraint_violation
|
6140 + | .as_validation_exception_field(path + "/" + key.as_str()),
|
6141 + | }
|
6142 + | }
|
6143 + | }
|
6144 + | }
|
6145 + | pub mod enum_list {
|
6146 + |
|
6147 + | #[allow(clippy::enum_variant_names)]
|
6148 + | #[derive(Debug, PartialEq)]
|
6149 + | 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),
|
6155 + | }
|
6156 + |
|
6157 + | impl ::std::fmt::Display for ConstraintViolation {
|
6158 + | 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}")
|
6166 + | }
|
6167 + | }
|
6168 + |
|
6169 + | impl ::std::error::Error for ConstraintViolation {}
|
6170 + | impl ConstraintViolation {
|
6171 + | pub(crate) fn as_validation_exception_field(
|
6172 + | self,
|
6173 + | path: ::std::string::String,
|
6174 + | ) -> crate::model::ValidationExceptionField {
|
6175 + | match self {
|
6176 + | Self::Member(index, member_constraint_violation) => member_constraint_violation
|
6177 + | .as_validation_exception_field(path + "/" + &index.to_string()),
|
6178 + | }
|
6179 + | }
|
6180 + | }
|
6181 + | }
|