aws_sdk_translate/operation/translate_text/
_translate_text_output.rs1#[allow(missing_docs)] #[non_exhaustive]
4#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
5pub struct TranslateTextOutput {
6 pub translated_text: ::std::string::String,
8 pub source_language_code: ::std::string::String,
10 pub target_language_code: ::std::string::String,
12 pub applied_terminologies: ::std::option::Option<::std::vec::Vec<crate::types::AppliedTerminology>>,
14 pub applied_settings: ::std::option::Option<crate::types::TranslationSettings>,
16 _request_id: Option<String>,
17}
18impl TranslateTextOutput {
19 pub fn translated_text(&self) -> &str {
21 use std::ops::Deref;
22 self.translated_text.deref()
23 }
24 pub fn source_language_code(&self) -> &str {
26 use std::ops::Deref;
27 self.source_language_code.deref()
28 }
29 pub fn target_language_code(&self) -> &str {
31 use std::ops::Deref;
32 self.target_language_code.deref()
33 }
34 pub fn applied_terminologies(&self) -> &[crate::types::AppliedTerminology] {
38 self.applied_terminologies.as_deref().unwrap_or_default()
39 }
40 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 pub fn builder() -> crate::operation::translate_text::builders::TranslateTextOutputBuilder {
53 crate::operation::translate_text::builders::TranslateTextOutputBuilder::default()
54 }
55}
56
57#[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 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 pub fn set_translated_text(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
77 self.translated_text = input;
78 self
79 }
80 pub fn get_translated_text(&self) -> &::std::option::Option<::std::string::String> {
82 &self.translated_text
83 }
84 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 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 pub fn get_source_language_code(&self) -> &::std::option::Option<::std::string::String> {
97 &self.source_language_code
98 }
99 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 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 pub fn get_target_language_code(&self) -> &::std::option::Option<::std::string::String> {
112 &self.target_language_code
113 }
114 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 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 pub fn get_applied_terminologies(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::AppliedTerminology>> {
132 &self.applied_terminologies
133 }
134 pub fn applied_settings(mut self, input: crate::types::TranslationSettings) -> Self {
136 self.applied_settings = ::std::option::Option::Some(input);
137 self
138 }
139 pub fn set_applied_settings(mut self, input: ::std::option::Option<crate::types::TranslationSettings>) -> Self {
141 self.applied_settings = input;
142 self
143 }
144 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 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}