google_cloud_language_v2/
builders.rs1pub mod language_service {
18 use crate::Result;
19 use std::sync::Arc;
20
21 #[derive(Clone, Debug)]
23 pub struct RequestBuilder<R: std::default::Default> {
24 stub: Arc<dyn crate::stubs::dynamic::LanguageService>,
25 request: R,
26 options: gax::options::RequestOptions,
27 }
28
29 impl<R> RequestBuilder<R>
30 where
31 R: std::default::Default,
32 {
33 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
34 Self {
35 stub,
36 request: R::default(),
37 options: gax::options::RequestOptions::default(),
38 }
39 }
40 }
41
42 #[derive(Clone, Debug)]
44 pub struct AnalyzeSentiment(RequestBuilder<crate::model::AnalyzeSentimentRequest>);
45
46 impl AnalyzeSentiment {
47 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
48 Self(RequestBuilder::new(stub))
49 }
50
51 pub fn with_request<V: Into<crate::model::AnalyzeSentimentRequest>>(
53 mut self,
54 v: V,
55 ) -> Self {
56 self.0.request = v.into();
57 self
58 }
59
60 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
62 self.0.options = v.into();
63 self
64 }
65
66 pub async fn send(self) -> Result<crate::model::AnalyzeSentimentResponse> {
68 (*self.0.stub)
69 .analyze_sentiment(self.0.request, self.0.options)
70 .await
71 }
72
73 pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
75 mut self,
76 v: T,
77 ) -> Self {
78 self.0.request.document = v.into();
79 self
80 }
81
82 pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
84 self.0.request.encoding_type = v.into();
85 self
86 }
87 }
88
89 impl gax::options::RequestBuilder for AnalyzeSentiment {
90 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
91 &mut self.0.options
92 }
93 }
94
95 #[derive(Clone, Debug)]
97 pub struct AnalyzeEntities(RequestBuilder<crate::model::AnalyzeEntitiesRequest>);
98
99 impl AnalyzeEntities {
100 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
101 Self(RequestBuilder::new(stub))
102 }
103
104 pub fn with_request<V: Into<crate::model::AnalyzeEntitiesRequest>>(mut self, v: V) -> Self {
106 self.0.request = v.into();
107 self
108 }
109
110 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
112 self.0.options = v.into();
113 self
114 }
115
116 pub async fn send(self) -> Result<crate::model::AnalyzeEntitiesResponse> {
118 (*self.0.stub)
119 .analyze_entities(self.0.request, self.0.options)
120 .await
121 }
122
123 pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
125 mut self,
126 v: T,
127 ) -> Self {
128 self.0.request.document = v.into();
129 self
130 }
131
132 pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
134 self.0.request.encoding_type = v.into();
135 self
136 }
137 }
138
139 impl gax::options::RequestBuilder for AnalyzeEntities {
140 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
141 &mut self.0.options
142 }
143 }
144
145 #[derive(Clone, Debug)]
147 pub struct ClassifyText(RequestBuilder<crate::model::ClassifyTextRequest>);
148
149 impl ClassifyText {
150 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
151 Self(RequestBuilder::new(stub))
152 }
153
154 pub fn with_request<V: Into<crate::model::ClassifyTextRequest>>(mut self, v: V) -> Self {
156 self.0.request = v.into();
157 self
158 }
159
160 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
162 self.0.options = v.into();
163 self
164 }
165
166 pub async fn send(self) -> Result<crate::model::ClassifyTextResponse> {
168 (*self.0.stub)
169 .classify_text(self.0.request, self.0.options)
170 .await
171 }
172
173 pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
175 mut self,
176 v: T,
177 ) -> Self {
178 self.0.request.document = v.into();
179 self
180 }
181 }
182
183 impl gax::options::RequestBuilder for ClassifyText {
184 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
185 &mut self.0.options
186 }
187 }
188
189 #[derive(Clone, Debug)]
191 pub struct ModerateText(RequestBuilder<crate::model::ModerateTextRequest>);
192
193 impl ModerateText {
194 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
195 Self(RequestBuilder::new(stub))
196 }
197
198 pub fn with_request<V: Into<crate::model::ModerateTextRequest>>(mut self, v: V) -> Self {
200 self.0.request = v.into();
201 self
202 }
203
204 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
206 self.0.options = v.into();
207 self
208 }
209
210 pub async fn send(self) -> Result<crate::model::ModerateTextResponse> {
212 (*self.0.stub)
213 .moderate_text(self.0.request, self.0.options)
214 .await
215 }
216
217 pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
219 mut self,
220 v: T,
221 ) -> Self {
222 self.0.request.document = v.into();
223 self
224 }
225
226 pub fn set_model_version<T: Into<crate::model::moderate_text_request::ModelVersion>>(
228 mut self,
229 v: T,
230 ) -> Self {
231 self.0.request.model_version = v.into();
232 self
233 }
234 }
235
236 impl gax::options::RequestBuilder for ModerateText {
237 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
238 &mut self.0.options
239 }
240 }
241
242 #[derive(Clone, Debug)]
244 pub struct AnnotateText(RequestBuilder<crate::model::AnnotateTextRequest>);
245
246 impl AnnotateText {
247 pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
248 Self(RequestBuilder::new(stub))
249 }
250
251 pub fn with_request<V: Into<crate::model::AnnotateTextRequest>>(mut self, v: V) -> Self {
253 self.0.request = v.into();
254 self
255 }
256
257 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
259 self.0.options = v.into();
260 self
261 }
262
263 pub async fn send(self) -> Result<crate::model::AnnotateTextResponse> {
265 (*self.0.stub)
266 .annotate_text(self.0.request, self.0.options)
267 .await
268 }
269
270 pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
272 mut self,
273 v: T,
274 ) -> Self {
275 self.0.request.document = v.into();
276 self
277 }
278
279 pub fn set_features<
281 T: Into<std::option::Option<crate::model::annotate_text_request::Features>>,
282 >(
283 mut self,
284 v: T,
285 ) -> Self {
286 self.0.request.features = v.into();
287 self
288 }
289
290 pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
292 self.0.request.encoding_type = v.into();
293 self
294 }
295 }
296
297 impl gax::options::RequestBuilder for AnnotateText {
298 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
299 &mut self.0.options
300 }
301 }
302}