google_cloud_language_v2/
builder.rs1pub mod language_service {
18 use crate::Result;
19 use std::sync::Arc;
20
21 pub type ClientBuilder =
35 gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;
36
37 pub(crate) mod client {
38 use super::super::super::client::LanguageService;
39 pub struct Factory;
40 impl gax::client_builder::internal::ClientFactory for Factory {
41 type Client = LanguageService;
42 type Credentials = gaxi::options::Credentials;
43 async fn build(self, config: gaxi::options::ClientConfig) -> gax::Result<Self::Client> {
44 Self::Client::new(config).await
45 }
46 }
47 }
48
49 #[derive(Clone, Debug)]
51 pub(crate) struct RequestBuilder<R: std::default::Default> {
52 stub: Arc<dyn super::super::stub::dynamic::LanguageService>,
53 request: R,
54 options: gax::options::RequestOptions,
55 }
56
57 impl<R> RequestBuilder<R>
58 where
59 R: std::default::Default,
60 {
61 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::LanguageService>) -> Self {
62 Self {
63 stub,
64 request: R::default(),
65 options: gax::options::RequestOptions::default(),
66 }
67 }
68 }
69
70 #[derive(Clone, Debug)]
72 pub struct AnalyzeSentiment(RequestBuilder<crate::model::AnalyzeSentimentRequest>);
73
74 impl AnalyzeSentiment {
75 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::LanguageService>) -> Self {
76 Self(RequestBuilder::new(stub))
77 }
78
79 pub fn with_request<V: Into<crate::model::AnalyzeSentimentRequest>>(
81 mut self,
82 v: V,
83 ) -> Self {
84 self.0.request = v.into();
85 self
86 }
87
88 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
90 self.0.options = v.into();
91 self
92 }
93
94 pub async fn send(self) -> Result<crate::model::AnalyzeSentimentResponse> {
96 (*self.0.stub)
97 .analyze_sentiment(self.0.request, self.0.options)
98 .await
99 .map(gax::response::Response::into_body)
100 }
101
102 pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
104 mut self,
105 v: T,
106 ) -> Self {
107 self.0.request.document = v.into();
108 self
109 }
110
111 pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
113 self.0.request.encoding_type = v.into();
114 self
115 }
116 }
117
118 #[doc(hidden)]
119 impl gax::options::internal::RequestBuilder for AnalyzeSentiment {
120 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
121 &mut self.0.options
122 }
123 }
124
125 #[derive(Clone, Debug)]
127 pub struct AnalyzeEntities(RequestBuilder<crate::model::AnalyzeEntitiesRequest>);
128
129 impl AnalyzeEntities {
130 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::LanguageService>) -> Self {
131 Self(RequestBuilder::new(stub))
132 }
133
134 pub fn with_request<V: Into<crate::model::AnalyzeEntitiesRequest>>(mut self, v: V) -> Self {
136 self.0.request = v.into();
137 self
138 }
139
140 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
142 self.0.options = v.into();
143 self
144 }
145
146 pub async fn send(self) -> Result<crate::model::AnalyzeEntitiesResponse> {
148 (*self.0.stub)
149 .analyze_entities(self.0.request, self.0.options)
150 .await
151 .map(gax::response::Response::into_body)
152 }
153
154 pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
156 mut self,
157 v: T,
158 ) -> Self {
159 self.0.request.document = v.into();
160 self
161 }
162
163 pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
165 self.0.request.encoding_type = v.into();
166 self
167 }
168 }
169
170 #[doc(hidden)]
171 impl gax::options::internal::RequestBuilder for AnalyzeEntities {
172 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
173 &mut self.0.options
174 }
175 }
176
177 #[derive(Clone, Debug)]
179 pub struct ClassifyText(RequestBuilder<crate::model::ClassifyTextRequest>);
180
181 impl ClassifyText {
182 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::LanguageService>) -> Self {
183 Self(RequestBuilder::new(stub))
184 }
185
186 pub fn with_request<V: Into<crate::model::ClassifyTextRequest>>(mut self, v: V) -> Self {
188 self.0.request = v.into();
189 self
190 }
191
192 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
194 self.0.options = v.into();
195 self
196 }
197
198 pub async fn send(self) -> Result<crate::model::ClassifyTextResponse> {
200 (*self.0.stub)
201 .classify_text(self.0.request, self.0.options)
202 .await
203 .map(gax::response::Response::into_body)
204 }
205
206 pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
208 mut self,
209 v: T,
210 ) -> Self {
211 self.0.request.document = v.into();
212 self
213 }
214 }
215
216 #[doc(hidden)]
217 impl gax::options::internal::RequestBuilder for ClassifyText {
218 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
219 &mut self.0.options
220 }
221 }
222
223 #[derive(Clone, Debug)]
225 pub struct ModerateText(RequestBuilder<crate::model::ModerateTextRequest>);
226
227 impl ModerateText {
228 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::LanguageService>) -> Self {
229 Self(RequestBuilder::new(stub))
230 }
231
232 pub fn with_request<V: Into<crate::model::ModerateTextRequest>>(mut self, v: V) -> Self {
234 self.0.request = v.into();
235 self
236 }
237
238 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
240 self.0.options = v.into();
241 self
242 }
243
244 pub async fn send(self) -> Result<crate::model::ModerateTextResponse> {
246 (*self.0.stub)
247 .moderate_text(self.0.request, self.0.options)
248 .await
249 .map(gax::response::Response::into_body)
250 }
251
252 pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
254 mut self,
255 v: T,
256 ) -> Self {
257 self.0.request.document = v.into();
258 self
259 }
260
261 pub fn set_model_version<T: Into<crate::model::moderate_text_request::ModelVersion>>(
263 mut self,
264 v: T,
265 ) -> Self {
266 self.0.request.model_version = v.into();
267 self
268 }
269 }
270
271 #[doc(hidden)]
272 impl gax::options::internal::RequestBuilder for ModerateText {
273 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
274 &mut self.0.options
275 }
276 }
277
278 #[derive(Clone, Debug)]
280 pub struct AnnotateText(RequestBuilder<crate::model::AnnotateTextRequest>);
281
282 impl AnnotateText {
283 pub(crate) fn new(stub: Arc<dyn super::super::stub::dynamic::LanguageService>) -> Self {
284 Self(RequestBuilder::new(stub))
285 }
286
287 pub fn with_request<V: Into<crate::model::AnnotateTextRequest>>(mut self, v: V) -> Self {
289 self.0.request = v.into();
290 self
291 }
292
293 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
295 self.0.options = v.into();
296 self
297 }
298
299 pub async fn send(self) -> Result<crate::model::AnnotateTextResponse> {
301 (*self.0.stub)
302 .annotate_text(self.0.request, self.0.options)
303 .await
304 .map(gax::response::Response::into_body)
305 }
306
307 pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
309 mut self,
310 v: T,
311 ) -> Self {
312 self.0.request.document = v.into();
313 self
314 }
315
316 pub fn set_features<
318 T: Into<std::option::Option<crate::model::annotate_text_request::Features>>,
319 >(
320 mut self,
321 v: T,
322 ) -> Self {
323 self.0.request.features = v.into();
324 self
325 }
326
327 pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
329 self.0.request.encoding_type = v.into();
330 self
331 }
332 }
333
334 #[doc(hidden)]
335 impl gax::options::internal::RequestBuilder for AnnotateText {
336 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
337 &mut self.0.options
338 }
339 }
340}