1#[allow(clippy::derive_partial_eq_without_eq)]
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct TranslatedText {
4 #[prost(string, tag = "1")]
6 pub text: ::prost::alloc::string::String,
7 #[prost(string, tag = "2")]
10 pub detected_language_code: ::prost::alloc::string::String,
11}
12#[allow(clippy::derive_partial_eq_without_eq)]
13#[derive(Clone, PartialEq, ::prost::Message)]
14pub struct Language {
15 #[prost(string, tag = "1")]
18 pub code: ::prost::alloc::string::String,
19 #[prost(string, tag = "2")]
21 pub name: ::prost::alloc::string::String,
22}
23#[allow(clippy::derive_partial_eq_without_eq)]
24#[derive(Clone, PartialEq, ::prost::Message)]
25pub struct TranslateRequest {
26 #[prost(string, tag = "1")]
31 pub source_language_code: ::prost::alloc::string::String,
32 #[prost(string, tag = "2")]
35 pub target_language_code: ::prost::alloc::string::String,
36 #[prost(enumeration = "translate_request::Format", tag = "3")]
38 pub format: i32,
39 #[prost(string, repeated, tag = "4")]
42 pub texts: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
43 #[prost(string, tag = "5")]
47 pub folder_id: ::prost::alloc::string::String,
48 #[prost(string, tag = "6")]
50 pub model: ::prost::alloc::string::String,
51 #[prost(message, optional, tag = "7")]
53 pub glossary_config: ::core::option::Option<TranslateGlossaryConfig>,
54 #[prost(bool, tag = "8")]
56 pub speller: bool,
57}
58pub mod translate_request {
60 #[derive(
61 Clone,
62 Copy,
63 Debug,
64 PartialEq,
65 Eq,
66 Hash,
67 PartialOrd,
68 Ord,
69 ::prost::Enumeration
70 )]
71 #[repr(i32)]
72 pub enum Format {
73 Unspecified = 0,
74 PlainText = 1,
76 Html = 2,
78 }
79 impl Format {
80 pub fn as_str_name(&self) -> &'static str {
85 match self {
86 Format::Unspecified => "FORMAT_UNSPECIFIED",
87 Format::PlainText => "PLAIN_TEXT",
88 Format::Html => "HTML",
89 }
90 }
91 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
93 match value {
94 "FORMAT_UNSPECIFIED" => Some(Self::Unspecified),
95 "PLAIN_TEXT" => Some(Self::PlainText),
96 "HTML" => Some(Self::Html),
97 _ => None,
98 }
99 }
100 }
101}
102#[allow(clippy::derive_partial_eq_without_eq)]
103#[derive(Clone, PartialEq, ::prost::Message)]
104pub struct TranslateGlossaryConfig {
105 #[prost(oneof = "translate_glossary_config::GlossarySource", tags = "1")]
106 pub glossary_source: ::core::option::Option<
107 translate_glossary_config::GlossarySource,
108 >,
109}
110pub mod translate_glossary_config {
112 #[allow(clippy::derive_partial_eq_without_eq)]
113 #[derive(Clone, PartialEq, ::prost::Oneof)]
114 pub enum GlossarySource {
115 #[prost(message, tag = "1")]
117 GlossaryData(super::GlossaryData),
118 }
119}
120#[allow(clippy::derive_partial_eq_without_eq)]
121#[derive(Clone, PartialEq, ::prost::Message)]
122pub struct GlossaryData {
123 #[prost(message, repeated, tag = "1")]
128 pub glossary_pairs: ::prost::alloc::vec::Vec<GlossaryPair>,
129}
130#[allow(clippy::derive_partial_eq_without_eq)]
131#[derive(Clone, PartialEq, ::prost::Message)]
132pub struct GlossaryPair {
133 #[prost(string, tag = "1")]
135 pub source_text: ::prost::alloc::string::String,
136 #[prost(string, tag = "2")]
138 pub translated_text: ::prost::alloc::string::String,
139 #[prost(bool, tag = "3")]
141 pub exact: bool,
142}
143#[allow(clippy::derive_partial_eq_without_eq)]
144#[derive(Clone, PartialEq, ::prost::Message)]
145pub struct TranslateResponse {
146 #[prost(message, repeated, tag = "1")]
148 pub translations: ::prost::alloc::vec::Vec<TranslatedText>,
149}
150#[allow(clippy::derive_partial_eq_without_eq)]
151#[derive(Clone, PartialEq, ::prost::Message)]
152pub struct DetectLanguageRequest {
153 #[prost(string, tag = "1")]
155 pub text: ::prost::alloc::string::String,
156 #[prost(string, repeated, tag = "2")]
161 pub language_code_hints: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
162 #[prost(string, tag = "3")]
166 pub folder_id: ::prost::alloc::string::String,
167}
168#[allow(clippy::derive_partial_eq_without_eq)]
169#[derive(Clone, PartialEq, ::prost::Message)]
170pub struct DetectLanguageResponse {
171 #[prost(string, tag = "1")]
175 pub language_code: ::prost::alloc::string::String,
176}
177#[allow(clippy::derive_partial_eq_without_eq)]
178#[derive(Clone, PartialEq, ::prost::Message)]
179pub struct ListLanguagesRequest {
180 #[prost(string, tag = "1")]
184 pub folder_id: ::prost::alloc::string::String,
185}
186#[allow(clippy::derive_partial_eq_without_eq)]
187#[derive(Clone, PartialEq, ::prost::Message)]
188pub struct ListLanguagesResponse {
189 #[prost(message, repeated, tag = "1")]
191 pub languages: ::prost::alloc::vec::Vec<Language>,
192}
193pub mod translation_service_client {
195 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
196 use tonic::codegen::*;
197 use tonic::codegen::http::Uri;
198 #[derive(Debug, Clone)]
202 pub struct TranslationServiceClient<T> {
203 inner: tonic::client::Grpc<T>,
204 }
205 impl TranslationServiceClient<tonic::transport::Channel> {
206 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
208 where
209 D: TryInto<tonic::transport::Endpoint>,
210 D::Error: Into<StdError>,
211 {
212 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
213 Ok(Self::new(conn))
214 }
215 }
216 impl<T> TranslationServiceClient<T>
217 where
218 T: tonic::client::GrpcService<tonic::body::BoxBody>,
219 T::Error: Into<StdError>,
220 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
221 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
222 {
223 pub fn new(inner: T) -> Self {
224 let inner = tonic::client::Grpc::new(inner);
225 Self { inner }
226 }
227 pub fn with_origin(inner: T, origin: Uri) -> Self {
228 let inner = tonic::client::Grpc::with_origin(inner, origin);
229 Self { inner }
230 }
231 pub fn with_interceptor<F>(
232 inner: T,
233 interceptor: F,
234 ) -> TranslationServiceClient<InterceptedService<T, F>>
235 where
236 F: tonic::service::Interceptor,
237 T::ResponseBody: Default,
238 T: tonic::codegen::Service<
239 http::Request<tonic::body::BoxBody>,
240 Response = http::Response<
241 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
242 >,
243 >,
244 <T as tonic::codegen::Service<
245 http::Request<tonic::body::BoxBody>,
246 >>::Error: Into<StdError> + Send + Sync,
247 {
248 TranslationServiceClient::new(InterceptedService::new(inner, interceptor))
249 }
250 #[must_use]
255 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
256 self.inner = self.inner.send_compressed(encoding);
257 self
258 }
259 #[must_use]
261 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
262 self.inner = self.inner.accept_compressed(encoding);
263 self
264 }
265 #[must_use]
269 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
270 self.inner = self.inner.max_decoding_message_size(limit);
271 self
272 }
273 #[must_use]
277 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
278 self.inner = self.inner.max_encoding_message_size(limit);
279 self
280 }
281 pub async fn translate(
283 &mut self,
284 request: impl tonic::IntoRequest<super::TranslateRequest>,
285 ) -> std::result::Result<
286 tonic::Response<super::TranslateResponse>,
287 tonic::Status,
288 > {
289 self.inner
290 .ready()
291 .await
292 .map_err(|e| {
293 tonic::Status::new(
294 tonic::Code::Unknown,
295 format!("Service was not ready: {}", e.into()),
296 )
297 })?;
298 let codec = tonic::codec::ProstCodec::default();
299 let path = http::uri::PathAndQuery::from_static(
300 "/yandex.cloud.ai.translate.v2.TranslationService/Translate",
301 );
302 let mut req = request.into_request();
303 req.extensions_mut()
304 .insert(
305 GrpcMethod::new(
306 "yandex.cloud.ai.translate.v2.TranslationService",
307 "Translate",
308 ),
309 );
310 self.inner.unary(req, path, codec).await
311 }
312 pub async fn detect_language(
314 &mut self,
315 request: impl tonic::IntoRequest<super::DetectLanguageRequest>,
316 ) -> std::result::Result<
317 tonic::Response<super::DetectLanguageResponse>,
318 tonic::Status,
319 > {
320 self.inner
321 .ready()
322 .await
323 .map_err(|e| {
324 tonic::Status::new(
325 tonic::Code::Unknown,
326 format!("Service was not ready: {}", e.into()),
327 )
328 })?;
329 let codec = tonic::codec::ProstCodec::default();
330 let path = http::uri::PathAndQuery::from_static(
331 "/yandex.cloud.ai.translate.v2.TranslationService/DetectLanguage",
332 );
333 let mut req = request.into_request();
334 req.extensions_mut()
335 .insert(
336 GrpcMethod::new(
337 "yandex.cloud.ai.translate.v2.TranslationService",
338 "DetectLanguage",
339 ),
340 );
341 self.inner.unary(req, path, codec).await
342 }
343 pub async fn list_languages(
345 &mut self,
346 request: impl tonic::IntoRequest<super::ListLanguagesRequest>,
347 ) -> std::result::Result<
348 tonic::Response<super::ListLanguagesResponse>,
349 tonic::Status,
350 > {
351 self.inner
352 .ready()
353 .await
354 .map_err(|e| {
355 tonic::Status::new(
356 tonic::Code::Unknown,
357 format!("Service was not ready: {}", e.into()),
358 )
359 })?;
360 let codec = tonic::codec::ProstCodec::default();
361 let path = http::uri::PathAndQuery::from_static(
362 "/yandex.cloud.ai.translate.v2.TranslationService/ListLanguages",
363 );
364 let mut req = request.into_request();
365 req.extensions_mut()
366 .insert(
367 GrpcMethod::new(
368 "yandex.cloud.ai.translate.v2.TranslationService",
369 "ListLanguages",
370 ),
371 );
372 self.inner.unary(req, path, codec).await
373 }
374 }
375}