aws_sdk_translate/operation/translate_text/
_translate_text_output.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(missing_docs)] // documentation missing in model
3#[non_exhaustive]
4#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
5pub struct TranslateTextOutput {
6    /// <p>The translated text.</p>
7    pub translated_text: ::std::string::String,
8    /// <p>The language code for the language of the source text.</p>
9    pub source_language_code: ::std::string::String,
10    /// <p>The language code for the language of the target text.</p>
11    pub target_language_code: ::std::string::String,
12    /// <p>The names of the custom terminologies applied to the input text by Amazon Translate for the translated text response.</p>
13    pub applied_terminologies: ::std::option::Option<::std::vec::Vec<crate::types::AppliedTerminology>>,
14    /// <p>Optional settings that modify the translation output.</p>
15    pub applied_settings: ::std::option::Option<crate::types::TranslationSettings>,
16    _request_id: Option<String>,
17}
18impl TranslateTextOutput {
19    /// <p>The translated text.</p>
20    pub fn translated_text(&self) -> &str {
21        use std::ops::Deref;
22        self.translated_text.deref()
23    }
24    /// <p>The language code for the language of the source text.</p>
25    pub fn source_language_code(&self) -> &str {
26        use std::ops::Deref;
27        self.source_language_code.deref()
28    }
29    /// <p>The language code for the language of the target text.</p>
30    pub fn target_language_code(&self) -> &str {
31        use std::ops::Deref;
32        self.target_language_code.deref()
33    }
34    /// <p>The names of the custom terminologies applied to the input text by Amazon Translate for the translated text response.</p>
35    ///
36    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.applied_terminologies.is_none()`.
37    pub fn applied_terminologies(&self) -> &[crate::types::AppliedTerminology] {
38        self.applied_terminologies.as_deref().unwrap_or_default()
39    }
40    /// <p>Optional settings that modify the translation output.</p>
41    pub fn applied_settings(&self) -> ::std::option::Option<&crate::types::TranslationSettings> {
42        self.applied_settings.as_ref()
43    }
44}
45impl ::aws_types::request_id::RequestId for TranslateTextOutput {
46    fn request_id(&self) -> Option<&str> {
47        self._request_id.as_deref()
48    }
49}
50impl TranslateTextOutput {
51    /// Creates a new builder-style object to manufacture [`TranslateTextOutput`](crate::operation::translate_text::TranslateTextOutput).
52    pub fn builder() -> crate::operation::translate_text::builders::TranslateTextOutputBuilder {
53        crate::operation::translate_text::builders::TranslateTextOutputBuilder::default()
54    }
55}
56
57/// A builder for [`TranslateTextOutput`](crate::operation::translate_text::TranslateTextOutput).
58#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
59#[non_exhaustive]
60pub struct TranslateTextOutputBuilder {
61    pub(crate) translated_text: ::std::option::Option<::std::string::String>,
62    pub(crate) source_language_code: ::std::option::Option<::std::string::String>,
63    pub(crate) target_language_code: ::std::option::Option<::std::string::String>,
64    pub(crate) applied_terminologies: ::std::option::Option<::std::vec::Vec<crate::types::AppliedTerminology>>,
65    pub(crate) applied_settings: ::std::option::Option<crate::types::TranslationSettings>,
66    _request_id: Option<String>,
67}
68impl TranslateTextOutputBuilder {
69    /// <p>The translated text.</p>
70    /// This field is required.
71    pub fn translated_text(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
72        self.translated_text = ::std::option::Option::Some(input.into());
73        self
74    }
75    /// <p>The translated text.</p>
76    pub fn set_translated_text(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
77        self.translated_text = input;
78        self
79    }
80    /// <p>The translated text.</p>
81    pub fn get_translated_text(&self) -> &::std::option::Option<::std::string::String> {
82        &self.translated_text
83    }
84    /// <p>The language code for the language of the source text.</p>
85    /// This field is required.
86    pub fn source_language_code(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
87        self.source_language_code = ::std::option::Option::Some(input.into());
88        self
89    }
90    /// <p>The language code for the language of the source text.</p>
91    pub fn set_source_language_code(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
92        self.source_language_code = input;
93        self
94    }
95    /// <p>The language code for the language of the source text.</p>
96    pub fn get_source_language_code(&self) -> &::std::option::Option<::std::string::String> {
97        &self.source_language_code
98    }
99    /// <p>The language code for the language of the target text.</p>
100    /// This field is required.
101    pub fn target_language_code(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
102        self.target_language_code = ::std::option::Option::Some(input.into());
103        self
104    }
105    /// <p>The language code for the language of the target text.</p>
106    pub fn set_target_language_code(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
107        self.target_language_code = input;
108        self
109    }
110    /// <p>The language code for the language of the target text.</p>
111    pub fn get_target_language_code(&self) -> &::std::option::Option<::std::string::String> {
112        &self.target_language_code
113    }
114    /// Appends an item to `applied_terminologies`.
115    ///
116    /// To override the contents of this collection use [`set_applied_terminologies`](Self::set_applied_terminologies).
117    ///
118    /// <p>The names of the custom terminologies applied to the input text by Amazon Translate for the translated text response.</p>
119    pub fn applied_terminologies(mut self, input: crate::types::AppliedTerminology) -> Self {
120        let mut v = self.applied_terminologies.unwrap_or_default();
121        v.push(input);
122        self.applied_terminologies = ::std::option::Option::Some(v);
123        self
124    }
125    /// <p>The names of the custom terminologies applied to the input text by Amazon Translate for the translated text response.</p>
126    pub fn set_applied_terminologies(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::AppliedTerminology>>) -> Self {
127        self.applied_terminologies = input;
128        self
129    }
130    /// <p>The names of the custom terminologies applied to the input text by Amazon Translate for the translated text response.</p>
131    pub fn get_applied_terminologies(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::AppliedTerminology>> {
132        &self.applied_terminologies
133    }
134    /// <p>Optional settings that modify the translation output.</p>
135    pub fn applied_settings(mut self, input: crate::types::TranslationSettings) -> Self {
136        self.applied_settings = ::std::option::Option::Some(input);
137        self
138    }
139    /// <p>Optional settings that modify the translation output.</p>
140    pub fn set_applied_settings(mut self, input: ::std::option::Option<crate::types::TranslationSettings>) -> Self {
141        self.applied_settings = input;
142        self
143    }
144    /// <p>Optional settings that modify the translation output.</p>
145    pub fn get_applied_settings(&self) -> &::std::option::Option<crate::types::TranslationSettings> {
146        &self.applied_settings
147    }
148    pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
149        self._request_id = Some(request_id.into());
150        self
151    }
152
153    pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
154        self._request_id = request_id;
155        self
156    }
157    /// Consumes the builder and constructs a [`TranslateTextOutput`](crate::operation::translate_text::TranslateTextOutput).
158    /// This method will fail if any of the following fields are not set:
159    /// - [`translated_text`](crate::operation::translate_text::builders::TranslateTextOutputBuilder::translated_text)
160    /// - [`source_language_code`](crate::operation::translate_text::builders::TranslateTextOutputBuilder::source_language_code)
161    /// - [`target_language_code`](crate::operation::translate_text::builders::TranslateTextOutputBuilder::target_language_code)
162    pub fn build(
163        self,
164    ) -> ::std::result::Result<crate::operation::translate_text::TranslateTextOutput, ::aws_smithy_types::error::operation::BuildError> {
165        ::std::result::Result::Ok(crate::operation::translate_text::TranslateTextOutput {
166            translated_text: self.translated_text.ok_or_else(|| {
167                ::aws_smithy_types::error::operation::BuildError::missing_field(
168                    "translated_text",
169                    "translated_text was not specified but it is required when building TranslateTextOutput",
170                )
171            })?,
172            source_language_code: self.source_language_code.ok_or_else(|| {
173                ::aws_smithy_types::error::operation::BuildError::missing_field(
174                    "source_language_code",
175                    "source_language_code was not specified but it is required when building TranslateTextOutput",
176                )
177            })?,
178            target_language_code: self.target_language_code.ok_or_else(|| {
179                ::aws_smithy_types::error::operation::BuildError::missing_field(
180                    "target_language_code",
181                    "target_language_code was not specified but it is required when building TranslateTextOutput",
182                )
183            })?,
184            applied_terminologies: self.applied_terminologies,
185            applied_settings: self.applied_settings,
186            _request_id: self._request_id,
187        })
188    }
189}