1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
/// The constraint a value failed, named for the Smithy trait or rule that declares it, with what it allows.
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub enum Constraint {
/// The value is not one of the enum's values.
Enum(crate::types::EnumConstraint),
/// The value's length is outside @length.
Length(crate::types::LengthConstraint),
/// The value doesn't match @pattern.
Pattern(crate::types::PatternConstraint),
/// The value is outside @range.
Range(crate::types::RangeConstraint),
/// The member is @required and missing. Always true when set.
Required(bool),
/// The value is not the member's type.
Type(crate::types::TypeConstraint),
/// The union sets no member or more than one. Always true when set.
Union(bool),
/// The `Unknown` variant represents cases where new union variant was received. Consider upgrading the SDK to the latest available version.
/// An unknown enum variant
///
/// _Note: If you encounter this error, consider upgrading your SDK to the latest version._
/// The `Unknown` variant represents cases where the server sent a value that wasn't recognized
/// by the client. This can happen when the server adds new functionality, but the client has not been updated.
/// To investigate this, consider turning on debug logging to print the raw HTTP response.
#[non_exhaustive]
Unknown,
}
impl Constraint {
/// Tries to convert the enum instance into [`Enum`](crate::types::Constraint::Enum), extracting the inner [`EnumConstraint`](crate::types::EnumConstraint).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_enum(&self) -> ::std::result::Result<&crate::types::EnumConstraint, &Self> {
if let Constraint::Enum(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`Enum`](crate::types::Constraint::Enum).
pub fn is_enum(&self) -> bool {
self.as_enum().is_ok()
}
/// Tries to convert the enum instance into [`Length`](crate::types::Constraint::Length), extracting the inner [`LengthConstraint`](crate::types::LengthConstraint).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_length(&self) -> ::std::result::Result<&crate::types::LengthConstraint, &Self> {
if let Constraint::Length(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`Length`](crate::types::Constraint::Length).
pub fn is_length(&self) -> bool {
self.as_length().is_ok()
}
/// Tries to convert the enum instance into [`Pattern`](crate::types::Constraint::Pattern), extracting the inner [`PatternConstraint`](crate::types::PatternConstraint).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_pattern(&self) -> ::std::result::Result<&crate::types::PatternConstraint, &Self> {
if let Constraint::Pattern(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`Pattern`](crate::types::Constraint::Pattern).
pub fn is_pattern(&self) -> bool {
self.as_pattern().is_ok()
}
/// Tries to convert the enum instance into [`Range`](crate::types::Constraint::Range), extracting the inner [`RangeConstraint`](crate::types::RangeConstraint).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_range(&self) -> ::std::result::Result<&crate::types::RangeConstraint, &Self> {
if let Constraint::Range(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`Range`](crate::types::Constraint::Range).
pub fn is_range(&self) -> bool {
self.as_range().is_ok()
}
/// Tries to convert the enum instance into [`Required`](crate::types::Constraint::Required), extracting the inner [`bool`](bool).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_required(&self) -> ::std::result::Result<&bool, &Self> {
if let Constraint::Required(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`Required`](crate::types::Constraint::Required).
pub fn is_required(&self) -> bool {
self.as_required().is_ok()
}
/// Tries to convert the enum instance into [`Type`](crate::types::Constraint::Type), extracting the inner [`TypeConstraint`](crate::types::TypeConstraint).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_type(&self) -> ::std::result::Result<&crate::types::TypeConstraint, &Self> {
if let Constraint::Type(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`Type`](crate::types::Constraint::Type).
pub fn is_type(&self) -> bool {
self.as_type().is_ok()
}
/// Tries to convert the enum instance into [`Union`](crate::types::Constraint::Union), extracting the inner [`bool`](bool).
/// Returns `Err(&Self)` if it can't be converted.
pub fn as_union(&self) -> ::std::result::Result<&bool, &Self> {
if let Constraint::Union(val) = &self {
::std::result::Result::Ok(val)
} else {
::std::result::Result::Err(self)
}
}
/// Returns true if this is a [`Union`](crate::types::Constraint::Union).
pub fn is_union(&self) -> bool {
self.as_union().is_ok()
}
/// Returns true if the enum instance is the `Unknown` variant.
pub fn is_unknown(&self) -> bool {
matches!(self, Self::Unknown)
}
}