1796 1796 | #[allow(missing_docs)] // documentation missing in model
|
1797 1797 | pub(crate) fn set_dialog_list(
|
1798 1798 | mut self,
|
1799 1799 | input: impl ::std::convert::Into<::std::vec::Vec<crate::model::Dialog>>,
|
1800 1800 | ) -> Self {
|
1801 1801 | self.dialog_list = Some(input.into());
|
1802 1802 | self
|
1803 1803 | }
|
1804 1804 | #[allow(missing_docs)] // documentation missing in model
|
1805 1805 | pub(crate) fn set_dialog_map(
|
1806 1806 | mut self,
|
1807 1807 | input: impl ::std::convert::Into<
|
1808 1808 | ::std::collections::HashMap<::std::string::String, crate::model::Dialog>,
|
1809 1809 | >,
|
1810 1810 | ) -> Self {
|
1811 1811 | self.dialog_map = Some(input.into());
|
1812 1812 | self
|
1813 1813 | }
|
1814 1814 | /// Consumes the builder and constructs a [`TopLevel`](crate::model::TopLevel).
|
1815 1815 | ///
|
1816 1816 | /// The builder fails to construct a [`TopLevel`](crate::model::TopLevel) if a [`ConstraintViolation`] occurs.
|
1817 1817 | ///
|
1818 1818 | pub fn build(self) -> Result<crate::model::TopLevel, ConstraintViolation> {
|
1819 1819 | self.build_enforcing_all_constraints()
|
1820 1820 | }
|
1821 1821 | fn build_enforcing_all_constraints(
|
1822 1822 | self,
|
1823 1823 | ) -> Result<crate::model::TopLevel, ConstraintViolation> {
|
1824 1824 | Ok(crate::model::TopLevel {
|
1825 1825 | dialog: self.dialog.ok_or(ConstraintViolation::MissingDialog)?,
|
1826 - | dialog_list: self.dialog_list.unwrap_or_else(
|
1827 - | #[allow(clippy::redundant_closure)]
|
1828 - | || ::std::vec::Vec::new(),
|
1829 - | ),
|
1830 - | dialog_map: self.dialog_map.unwrap_or_else(
|
1831 - | #[allow(clippy::redundant_closure)]
|
1832 - | || ::std::collections::HashMap::new(),
|
1833 - | ),
|
1826 + | dialog_list: self.dialog_list.unwrap_or_default(),
|
1827 + | dialog_map: self.dialog_map.unwrap_or_default(),
|
1834 1828 | })
|
1835 1829 | }
|
1836 1830 | }
|
1837 1831 | }
|
1838 1832 | /// See [`TopLevel`](crate::model::TopLevel).
|
1839 1833 | pub mod top_level {
|
1840 1834 |
|
1841 1835 | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
1842 1836 | /// Holds one variant for each of the ways the builder can fail.
|
1843 1837 |
|
1844 1838 | #[allow(clippy::enum_variant_names)]
|
1845 1839 | pub enum ConstraintViolation {
|
1846 1840 | /// `dialog` was not provided but it is required when building `TopLevel`.
|
1847 1841 | MissingDialog,
|
1848 1842 | }
|
1849 1843 | impl ::std::fmt::Display for ConstraintViolation {
|
1850 1844 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
1851 1845 | match self {
|
1852 1846 | ConstraintViolation::MissingDialog => write!(
|
1853 1847 | f,
|
1854 1848 | "`dialog` was not provided but it is required when building `TopLevel`"
|
1855 1849 | ),
|
1856 1850 | }
|
1857 1851 | }
|
1858 1852 | }
|
1859 1853 | impl ::std::error::Error for ConstraintViolation {}
|
1860 1854 | impl ::std::convert::TryFrom<Builder> for crate::model::TopLevel {
|
1861 1855 | type Error = ConstraintViolation;
|
1862 1856 |
|
1863 1857 | fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
|
1877 1871 | #[allow(missing_docs)] // documentation missing in model
|
1878 1872 | pub fn dialog(mut self, input: crate::model::Dialog) -> Self {
|
1879 1873 | self.dialog = Some(input);
|
1880 1874 | self
|
1881 1875 | }
|
1882 1876 | #[allow(missing_docs)] // documentation missing in model
|
1883 1877 | pub fn dialog_list(mut self, input: ::std::vec::Vec<crate::model::Dialog>) -> Self {
|
1884 1878 | self.dialog_list = Some(input);
|
1885 1879 | self
|
1886 1880 | }
|
1887 1881 | #[allow(missing_docs)] // documentation missing in model
|
1888 1882 | pub fn dialog_map(
|
1889 1883 | mut self,
|
1890 1884 | input: ::std::collections::HashMap<::std::string::String, crate::model::Dialog>,
|
1891 1885 | ) -> Self {
|
1892 1886 | self.dialog_map = Some(input);
|
1893 1887 | self
|
1894 1888 | }
|
1895 1889 | /// Consumes the builder and constructs a [`TopLevel`](crate::model::TopLevel).
|
1896 1890 | ///
|
1897 1891 | /// The builder fails to construct a [`TopLevel`](crate::model::TopLevel) if you do not provide a value for all non-`Option`al members.
|
1898 1892 | ///
|
1899 1893 | pub fn build(self) -> Result<crate::model::TopLevel, ConstraintViolation> {
|
1900 1894 | self.build_enforcing_required_and_enum_traits()
|
1901 1895 | }
|
1902 1896 | fn build_enforcing_required_and_enum_traits(
|
1903 1897 | self,
|
1904 1898 | ) -> Result<crate::model::TopLevel, ConstraintViolation> {
|
1905 1899 | Ok(crate::model::TopLevel {
|
1906 1900 | dialog: self.dialog.ok_or(ConstraintViolation::MissingDialog)?,
|
1907 - | dialog_list: self.dialog_list.unwrap_or_else(
|
1908 - | #[allow(clippy::redundant_closure)]
|
1909 - | || ::std::vec::Vec::new(),
|
1910 - | ),
|
1911 - | dialog_map: self.dialog_map.unwrap_or_else(
|
1912 - | #[allow(clippy::redundant_closure)]
|
1913 - | || ::std::collections::HashMap::new(),
|
1914 - | ),
|
1901 + | dialog_list: self.dialog_list.unwrap_or_default(),
|
1902 + | dialog_map: self.dialog_map.unwrap_or_default(),
|
1915 1903 | })
|
1916 1904 | }
|
1917 1905 | }
|
1918 1906 | }
|
1919 1907 | /// See [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
1920 1908 | pub(crate) mod client_optional_defaults_internal {
|
1921 1909 |
|
1922 1910 | impl ::std::convert::From<Builder> for crate::model::ClientOptionalDefaults {
|
1923 1911 | fn from(builder: Builder) -> Self {
|
1924 1912 | builder.build()
|
1925 1913 | }
|
1926 1914 | }
|
1927 1915 | /// A builder for [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
1928 1916 | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
1929 1917 | pub(crate) struct Builder {
|
1930 1918 | pub(crate) member: ::std::option::Option<i32>,
|
1931 1919 | }
|
1932 1920 | impl Builder {
|
1933 1921 | #[allow(missing_docs)] // documentation missing in model
|
1934 1922 | pub(crate) fn set_member(mut self, input: impl ::std::convert::Into<i32>) -> Self {
|
1935 1923 | self.member = Some(input.into());
|
1936 1924 | self
|
1937 1925 | }
|
1938 1926 | /// Consumes the builder and constructs a [`ClientOptionalDefaults`](crate::model::ClientOptionalDefaults).
|
1939 1927 | pub fn build(self) -> crate::model::ClientOptionalDefaults {
|
1940 1928 | self.build_enforcing_all_constraints()
|
1941 1929 | }
|
1942 1930 | fn build_enforcing_all_constraints(self) -> crate::model::ClientOptionalDefaults {
|
1943 1931 | crate::model::ClientOptionalDefaults {
|
1944 1932 | member: self.member.unwrap_or(0i32),
|
2245 2233 | pub(crate) fn set_zero_long(mut self, input: impl ::std::convert::Into<i64>) -> Self {
|
2246 2234 | self.zero_long = Some(input.into());
|
2247 2235 | self
|
2248 2236 | }
|
2249 2237 | #[allow(missing_docs)] // documentation missing in model
|
2250 2238 | pub(crate) fn set_zero_float(mut self, input: impl ::std::convert::Into<f32>) -> Self {
|
2251 2239 | self.zero_float = Some(input.into());
|
2252 2240 | self
|
2253 2241 | }
|
2254 2242 | #[allow(missing_docs)] // documentation missing in model
|
2255 2243 | pub(crate) fn set_zero_double(mut self, input: impl ::std::convert::Into<f64>) -> Self {
|
2256 2244 | self.zero_double = Some(input.into());
|
2257 2245 | self
|
2258 2246 | }
|
2259 2247 | /// Consumes the builder and constructs a [`Defaults`](crate::model::Defaults).
|
2260 2248 | ///
|
2261 2249 | /// The builder fails to construct a [`Defaults`](crate::model::Defaults) if a [`ConstraintViolation`] occurs.
|
2262 2250 | ///
|
2263 2251 | pub fn build(self) -> Result<crate::model::Defaults, ConstraintViolation> {
|
2264 2252 | self.build_enforcing_all_constraints()
|
2265 2253 | }
|
2266 2254 | fn build_enforcing_all_constraints(
|
2267 2255 | self,
|
2268 2256 | ) -> Result<crate::model::Defaults, ConstraintViolation> {
|
2269 2257 | Ok(crate::model::Defaults {
|
2270 2258 | default_string: self.default_string.unwrap_or_else(
|
2271 2259 | #[allow(clippy::redundant_closure)]
|
2272 2260 | || String::from("hi"),
|
2273 2261 | ),
|
2274 2262 | default_boolean: self.default_boolean.unwrap_or(true),
|
2275 - | default_list: self.default_list.unwrap_or_else(
|
2276 - | #[allow(clippy::redundant_closure)]
|
2277 - | || ::std::vec::Vec::new(),
|
2278 - | ),
|
2263 + | default_list: self.default_list.unwrap_or_default(),
|
2279 2264 | default_document_map: self.default_document_map.unwrap_or_else(
|
2280 2265 | #[allow(clippy::redundant_closure)]
|
2281 2266 | || {
|
2282 2267 | ::aws_smithy_types::Document::Object(::std::collections::HashMap::new())
|
2283 2268 | .into()
|
2284 2269 | },
|
2285 2270 | ),
|
2286 2271 | default_document_string: self.default_document_string.unwrap_or_else(
|
2287 2272 | #[allow(clippy::redundant_closure)]
|
2288 2273 | || {
|
2289 2274 | ::aws_smithy_types::Document::String(::std::string::String::from("hi"))
|
2290 2275 | .into()
|
2291 2276 | },
|
2292 2277 | ),
|
2293 2278 | default_document_boolean: self
|
2294 2279 | .default_document_boolean
|
2295 2280 | .unwrap_or(::aws_smithy_types::Document::Bool(true).into()),
|
2296 2281 | default_document_list: self.default_document_list.unwrap_or_else(
|
2297 2282 | #[allow(clippy::redundant_closure)]
|
2298 2283 | || ::aws_smithy_types::Document::Array(::std::vec::Vec::new()).into(),
|
2299 2284 | ),
|
2300 2285 | default_null_document: self.default_null_document,
|
2301 2286 | default_timestamp: self.default_timestamp.unwrap_or_else(
|
2302 2287 | #[allow(clippy::redundant_closure)]
|
2303 2288 | || ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64).into(),
|
2304 2289 | ),
|
2305 2290 | default_blob: self.default_blob.unwrap_or_else(
|
2306 2291 | #[allow(clippy::redundant_closure)]
|
2307 2292 | || ::aws_smithy_types::Blob::new("abc").into(),
|
2308 2293 | ),
|
2309 2294 | default_byte: self.default_byte.unwrap_or(1i8),
|
2310 2295 | default_short: self.default_short.unwrap_or(1i16),
|
2311 2296 | default_integer: self.default_integer.unwrap_or(10i32),
|
2312 2297 | default_long: self.default_long.unwrap_or(100i64),
|
2313 2298 | default_float: self.default_float.unwrap_or(1.0f32),
|
2314 2299 | default_double: self.default_double.unwrap_or(1.0f64),
|
2315 - | default_map: self.default_map.unwrap_or_else(
|
2316 - | #[allow(clippy::redundant_closure)]
|
2317 - | || ::std::collections::HashMap::new(),
|
2318 - | ),
|
2300 + | default_map: self.default_map.unwrap_or_default(),
|
2319 2301 | default_enum: self
|
2320 2302 | .default_enum
|
2321 2303 | .map(|v| match v {
|
2322 2304 | crate::constrained::MaybeConstrained::Constrained(x) => Ok(x),
|
2323 2305 | crate::constrained::MaybeConstrained::Unconstrained(x) => x.try_into(),
|
2324 2306 | })
|
2325 2307 | .map(|res| res.map_err(ConstraintViolation::DefaultEnum))
|
2326 2308 | .transpose()?
|
2327 2309 | .unwrap_or(
|
2328 2310 | "FOO"
|
2329 2311 | .parse::<crate::model::TestEnum>()
|
2330 2312 | .expect("static value validated to member"),
|
2331 2313 | ),
|
2332 2314 | default_int_enum: self.default_int_enum.unwrap_or(1i32),
|
2333 2315 | empty_string: self.empty_string.unwrap_or_else(
|
2334 2316 | #[allow(clippy::redundant_closure)]
|
2335 2317 | || String::from(""),
|
2336 2318 | ),
|
2337 2319 | false_boolean: self.false_boolean.unwrap_or(false),
|
2338 2320 | empty_blob: self.empty_blob.unwrap_or_else(
|
2339 2321 | #[allow(clippy::redundant_closure)]
|
2340 2322 | || ::aws_smithy_types::Blob::new("").into(),
|
2341 2323 | ),
|
2342 2324 | zero_byte: self.zero_byte.unwrap_or(0i8),
|
2343 2325 | zero_short: self.zero_short.unwrap_or(0i16),
|
2344 2326 | zero_integer: self.zero_integer.unwrap_or(0i32),
|
2345 2327 | zero_long: self.zero_long.unwrap_or(0i64),
|
2346 2328 | zero_float: self.zero_float.unwrap_or(0.0f32),
|
2347 2329 | zero_double: self.zero_double.unwrap_or(0.0f64),
|
2348 2330 | })
|
2544 2526 | pub fn zero_integer(mut self, input: i32) -> Self {
|
2545 2527 | self.zero_integer = Some(input);
|
2546 2528 | self
|
2547 2529 | }
|
2548 2530 | #[allow(missing_docs)] // documentation missing in model
|
2549 2531 | pub fn zero_long(mut self, input: i64) -> Self {
|
2550 2532 | self.zero_long = Some(input);
|
2551 2533 | self
|
2552 2534 | }
|
2553 2535 | #[allow(missing_docs)] // documentation missing in model
|
2554 2536 | pub fn zero_float(mut self, input: f32) -> Self {
|
2555 2537 | self.zero_float = Some(input);
|
2556 2538 | self
|
2557 2539 | }
|
2558 2540 | #[allow(missing_docs)] // documentation missing in model
|
2559 2541 | pub fn zero_double(mut self, input: f64) -> Self {
|
2560 2542 | self.zero_double = Some(input);
|
2561 2543 | self
|
2562 2544 | }
|
2563 2545 | /// Consumes the builder and constructs a [`Defaults`](crate::model::Defaults).
|
2564 2546 | pub fn build(self) -> crate::model::Defaults {
|
2565 2547 | self.build_enforcing_required_and_enum_traits()
|
2566 2548 | }
|
2567 2549 | fn build_enforcing_required_and_enum_traits(self) -> crate::model::Defaults {
|
2568 2550 | crate::model::Defaults {
|
2569 2551 | default_string: self.default_string.unwrap_or_else(
|
2570 2552 | #[allow(clippy::redundant_closure)]
|
2571 2553 | || String::from("hi"),
|
2572 2554 | ),
|
2573 2555 | default_boolean: self.default_boolean.unwrap_or(true),
|
2574 - | default_list: self.default_list.unwrap_or_else(
|
2575 - | #[allow(clippy::redundant_closure)]
|
2576 - | || ::std::vec::Vec::new(),
|
2577 - | ),
|
2556 + | default_list: self.default_list.unwrap_or_default(),
|
2578 2557 | default_document_map: self.default_document_map.unwrap_or_else(
|
2579 2558 | #[allow(clippy::redundant_closure)]
|
2580 2559 | || {
|
2581 2560 | ::aws_smithy_types::Document::Object(::std::collections::HashMap::new())
|
2582 2561 | .into()
|
2583 2562 | },
|
2584 2563 | ),
|
2585 2564 | default_document_string: self.default_document_string.unwrap_or_else(
|
2586 2565 | #[allow(clippy::redundant_closure)]
|
2587 2566 | || {
|
2588 2567 | ::aws_smithy_types::Document::String(::std::string::String::from("hi"))
|
2589 2568 | .into()
|
2590 2569 | },
|
2591 2570 | ),
|
2592 2571 | default_document_boolean: self
|
2593 2572 | .default_document_boolean
|
2594 2573 | .unwrap_or(::aws_smithy_types::Document::Bool(true).into()),
|
2595 2574 | default_document_list: self.default_document_list.unwrap_or_else(
|
2596 2575 | #[allow(clippy::redundant_closure)]
|
2597 2576 | || ::aws_smithy_types::Document::Array(::std::vec::Vec::new()).into(),
|
2598 2577 | ),
|
2599 2578 | default_null_document: self.default_null_document,
|
2600 2579 | default_timestamp: self.default_timestamp.unwrap_or_else(
|
2601 2580 | #[allow(clippy::redundant_closure)]
|
2602 2581 | || ::aws_smithy_types::DateTime::from_fractional_secs(0, 0_f64).into(),
|
2603 2582 | ),
|
2604 2583 | default_blob: self.default_blob.unwrap_or_else(
|
2605 2584 | #[allow(clippy::redundant_closure)]
|
2606 2585 | || ::aws_smithy_types::Blob::new("abc").into(),
|
2607 2586 | ),
|
2608 2587 | default_byte: self.default_byte.unwrap_or(1i8),
|
2609 2588 | default_short: self.default_short.unwrap_or(1i16),
|
2610 2589 | default_integer: self.default_integer.unwrap_or(10i32),
|
2611 2590 | default_long: self.default_long.unwrap_or(100i64),
|
2612 2591 | default_float: self.default_float.unwrap_or(1.0f32),
|
2613 2592 | default_double: self.default_double.unwrap_or(1.0f64),
|
2614 - | default_map: self.default_map.unwrap_or_else(
|
2615 - | #[allow(clippy::redundant_closure)]
|
2616 - | || ::std::collections::HashMap::new(),
|
2617 - | ),
|
2593 + | default_map: self.default_map.unwrap_or_default(),
|
2618 2594 | default_enum: self.default_enum.unwrap_or(
|
2619 2595 | "FOO"
|
2620 2596 | .parse::<crate::model::TestEnum>()
|
2621 2597 | .expect("static value validated to member"),
|
2622 2598 | ),
|
2623 2599 | default_int_enum: self.default_int_enum.unwrap_or(1i32),
|
2624 2600 | empty_string: self.empty_string.unwrap_or_else(
|
2625 2601 | #[allow(clippy::redundant_closure)]
|
2626 2602 | || String::from(""),
|
2627 2603 | ),
|
2628 2604 | false_boolean: self.false_boolean.unwrap_or(false),
|
2629 2605 | empty_blob: self.empty_blob.unwrap_or_else(
|
2630 2606 | #[allow(clippy::redundant_closure)]
|
2631 2607 | || ::aws_smithy_types::Blob::new("").into(),
|
2632 2608 | ),
|
2633 2609 | zero_byte: self.zero_byte.unwrap_or(0i8),
|
2634 2610 | zero_short: self.zero_short.unwrap_or(0i16),
|
2635 2611 | zero_integer: self.zero_integer.unwrap_or(0i32),
|
2636 2612 | zero_long: self.zero_long.unwrap_or(0i64),
|
2637 2613 | zero_float: self.zero_float.unwrap_or(0.0f32),
|
2638 2614 | zero_double: self.zero_double.unwrap_or(0.0f64),
|
2639 2615 | }
|
2640 2616 | }
|
2641 2617 | }
|
2642 2618 | }
|
2643 2619 | pub(crate) mod my_union_internal {
|
2644 2620 |
|
2645 2621 | #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
|
2646 2622 | #[allow(clippy::enum_variant_names)]
|
2647 2623 | pub(crate) enum ConstraintViolation {
|