Skip to main content

google_cloud_language_v2/
model.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gaxi;
23extern crate google_cloud_gax;
24extern crate serde;
25extern crate serde_json;
26extern crate serde_with;
27extern crate std;
28extern crate tracing;
29extern crate wkt;
30
31mod debug;
32mod deserialize;
33mod serialize;
34
35/// Represents the input to API methods.
36#[derive(Clone, Default, PartialEq)]
37#[non_exhaustive]
38pub struct Document {
39    /// Required. If the type is not set or is `TYPE_UNSPECIFIED`,
40    /// returns an `INVALID_ARGUMENT` error.
41    pub r#type: crate::model::document::Type,
42
43    /// Optional. The language of the document (if not specified, the language is
44    /// automatically detected). Both ISO and BCP-47 language codes are
45    /// accepted.\<br\>
46    /// [Language
47    /// Support](https://cloud.google.com/natural-language/docs/languages) lists
48    /// currently supported languages for each API method. If the language (either
49    /// specified by the caller or automatically detected) is not supported by the
50    /// called API method, an `INVALID_ARGUMENT` error is returned.
51    pub language_code: std::string::String,
52
53    /// The source of the document: a string containing the content or a
54    /// Google Cloud Storage URI.
55    pub source: std::option::Option<crate::model::document::Source>,
56
57    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
58}
59
60impl Document {
61    pub fn new() -> Self {
62        std::default::Default::default()
63    }
64
65    /// Sets the value of [r#type][crate::model::Document::type].
66    ///
67    /// # Example
68    /// ```ignore,no_run
69    /// # use google_cloud_language_v2::model::Document;
70    /// use google_cloud_language_v2::model::document::Type;
71    /// let x0 = Document::new().set_type(Type::PlainText);
72    /// let x1 = Document::new().set_type(Type::Html);
73    /// ```
74    pub fn set_type<T: std::convert::Into<crate::model::document::Type>>(mut self, v: T) -> Self {
75        self.r#type = v.into();
76        self
77    }
78
79    /// Sets the value of [language_code][crate::model::Document::language_code].
80    ///
81    /// # Example
82    /// ```ignore,no_run
83    /// # use google_cloud_language_v2::model::Document;
84    /// let x = Document::new().set_language_code("example");
85    /// ```
86    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
87        self.language_code = v.into();
88        self
89    }
90
91    /// Sets the value of [source][crate::model::Document::source].
92    ///
93    /// Note that all the setters affecting `source` are mutually
94    /// exclusive.
95    ///
96    /// # Example
97    /// ```ignore,no_run
98    /// # use google_cloud_language_v2::model::Document;
99    /// use google_cloud_language_v2::model::document::Source;
100    /// let x = Document::new().set_source(Some(Source::Content("example".to_string())));
101    /// ```
102    pub fn set_source<
103        T: std::convert::Into<std::option::Option<crate::model::document::Source>>,
104    >(
105        mut self,
106        v: T,
107    ) -> Self {
108        self.source = v.into();
109        self
110    }
111
112    /// The value of [source][crate::model::Document::source]
113    /// if it holds a `Content`, `None` if the field is not set or
114    /// holds a different branch.
115    pub fn content(&self) -> std::option::Option<&std::string::String> {
116        #[allow(unreachable_patterns)]
117        self.source.as_ref().and_then(|v| match v {
118            crate::model::document::Source::Content(v) => std::option::Option::Some(v),
119            _ => std::option::Option::None,
120        })
121    }
122
123    /// Sets the value of [source][crate::model::Document::source]
124    /// to hold a `Content`.
125    ///
126    /// Note that all the setters affecting `source` are
127    /// mutually exclusive.
128    ///
129    /// # Example
130    /// ```ignore,no_run
131    /// # use google_cloud_language_v2::model::Document;
132    /// let x = Document::new().set_content("example");
133    /// assert!(x.content().is_some());
134    /// assert!(x.gcs_content_uri().is_none());
135    /// ```
136    pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
137        self.source = std::option::Option::Some(crate::model::document::Source::Content(v.into()));
138        self
139    }
140
141    /// The value of [source][crate::model::Document::source]
142    /// if it holds a `GcsContentUri`, `None` if the field is not set or
143    /// holds a different branch.
144    pub fn gcs_content_uri(&self) -> std::option::Option<&std::string::String> {
145        #[allow(unreachable_patterns)]
146        self.source.as_ref().and_then(|v| match v {
147            crate::model::document::Source::GcsContentUri(v) => std::option::Option::Some(v),
148            _ => std::option::Option::None,
149        })
150    }
151
152    /// Sets the value of [source][crate::model::Document::source]
153    /// to hold a `GcsContentUri`.
154    ///
155    /// Note that all the setters affecting `source` are
156    /// mutually exclusive.
157    ///
158    /// # Example
159    /// ```ignore,no_run
160    /// # use google_cloud_language_v2::model::Document;
161    /// let x = Document::new().set_gcs_content_uri("example");
162    /// assert!(x.gcs_content_uri().is_some());
163    /// assert!(x.content().is_none());
164    /// ```
165    pub fn set_gcs_content_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
166        self.source =
167            std::option::Option::Some(crate::model::document::Source::GcsContentUri(v.into()));
168        self
169    }
170}
171
172impl wkt::message::Message for Document {
173    fn typename() -> &'static str {
174        "type.googleapis.com/google.cloud.language.v2.Document"
175    }
176}
177
178/// Defines additional types related to [Document].
179pub mod document {
180    #[allow(unused_imports)]
181    use super::*;
182
183    /// The document types enum.
184    ///
185    /// # Working with unknown values
186    ///
187    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
188    /// additional enum variants at any time. Adding new variants is not considered
189    /// a breaking change. Applications should write their code in anticipation of:
190    ///
191    /// - New values appearing in future releases of the client library, **and**
192    /// - New values received dynamically, without application changes.
193    ///
194    /// Please consult the [Working with enums] section in the user guide for some
195    /// guidelines.
196    ///
197    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
198    #[derive(Clone, Debug, PartialEq)]
199    #[non_exhaustive]
200    pub enum Type {
201        /// The content type is not specified.
202        Unspecified,
203        /// Plain text
204        PlainText,
205        /// HTML
206        Html,
207        /// If set, the enum was initialized with an unknown value.
208        ///
209        /// Applications can examine the value using [Type::value] or
210        /// [Type::name].
211        UnknownValue(r#type::UnknownValue),
212    }
213
214    #[doc(hidden)]
215    pub mod r#type {
216        #[allow(unused_imports)]
217        use super::*;
218        #[derive(Clone, Debug, PartialEq)]
219        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
220    }
221
222    impl Type {
223        /// Gets the enum value.
224        ///
225        /// Returns `None` if the enum contains an unknown value deserialized from
226        /// the string representation of enums.
227        pub fn value(&self) -> std::option::Option<i32> {
228            match self {
229                Self::Unspecified => std::option::Option::Some(0),
230                Self::PlainText => std::option::Option::Some(1),
231                Self::Html => std::option::Option::Some(2),
232                Self::UnknownValue(u) => u.0.value(),
233            }
234        }
235
236        /// Gets the enum value as a string.
237        ///
238        /// Returns `None` if the enum contains an unknown value deserialized from
239        /// the integer representation of enums.
240        pub fn name(&self) -> std::option::Option<&str> {
241            match self {
242                Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
243                Self::PlainText => std::option::Option::Some("PLAIN_TEXT"),
244                Self::Html => std::option::Option::Some("HTML"),
245                Self::UnknownValue(u) => u.0.name(),
246            }
247        }
248    }
249
250    impl std::default::Default for Type {
251        fn default() -> Self {
252            use std::convert::From;
253            Self::from(0)
254        }
255    }
256
257    impl std::fmt::Display for Type {
258        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
259            wkt::internal::display_enum(f, self.name(), self.value())
260        }
261    }
262
263    impl std::convert::From<i32> for Type {
264        fn from(value: i32) -> Self {
265            match value {
266                0 => Self::Unspecified,
267                1 => Self::PlainText,
268                2 => Self::Html,
269                _ => Self::UnknownValue(r#type::UnknownValue(
270                    wkt::internal::UnknownEnumValue::Integer(value),
271                )),
272            }
273        }
274    }
275
276    impl std::convert::From<&str> for Type {
277        fn from(value: &str) -> Self {
278            use std::string::ToString;
279            match value {
280                "TYPE_UNSPECIFIED" => Self::Unspecified,
281                "PLAIN_TEXT" => Self::PlainText,
282                "HTML" => Self::Html,
283                _ => Self::UnknownValue(r#type::UnknownValue(
284                    wkt::internal::UnknownEnumValue::String(value.to_string()),
285                )),
286            }
287        }
288    }
289
290    impl serde::ser::Serialize for Type {
291        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
292        where
293            S: serde::Serializer,
294        {
295            match self {
296                Self::Unspecified => serializer.serialize_i32(0),
297                Self::PlainText => serializer.serialize_i32(1),
298                Self::Html => serializer.serialize_i32(2),
299                Self::UnknownValue(u) => u.0.serialize(serializer),
300            }
301        }
302    }
303
304    impl<'de> serde::de::Deserialize<'de> for Type {
305        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
306        where
307            D: serde::Deserializer<'de>,
308        {
309            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
310                ".google.cloud.language.v2.Document.Type",
311            ))
312        }
313    }
314
315    /// The source of the document: a string containing the content or a
316    /// Google Cloud Storage URI.
317    #[derive(Clone, Debug, PartialEq)]
318    #[non_exhaustive]
319    pub enum Source {
320        /// The content of the input in string format.
321        /// Cloud audit logging exempt since it is based on user data.
322        Content(std::string::String),
323        /// The Google Cloud Storage URI where the file content is located.
324        /// This URI must be of the form: gs://bucket_name/object_name. For more
325        /// details, see <https://cloud.google.com/storage/docs/reference-uris>.
326        /// NOTE: Cloud Storage object versioning is not supported.
327        GcsContentUri(std::string::String),
328    }
329}
330
331/// Represents a sentence in the input document.
332#[derive(Clone, Default, PartialEq)]
333#[non_exhaustive]
334pub struct Sentence {
335    /// The sentence text.
336    pub text: std::option::Option<crate::model::TextSpan>,
337
338    /// For calls to [AnalyzeSentiment][] or if
339    /// [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment]
340    /// is set to true, this field will contain the sentiment for the sentence.
341    ///
342    /// [google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment]: crate::model::annotate_text_request::Features::extract_document_sentiment
343    pub sentiment: std::option::Option<crate::model::Sentiment>,
344
345    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
346}
347
348impl Sentence {
349    pub fn new() -> Self {
350        std::default::Default::default()
351    }
352
353    /// Sets the value of [text][crate::model::Sentence::text].
354    ///
355    /// # Example
356    /// ```ignore,no_run
357    /// # use google_cloud_language_v2::model::Sentence;
358    /// use google_cloud_language_v2::model::TextSpan;
359    /// let x = Sentence::new().set_text(TextSpan::default()/* use setters */);
360    /// ```
361    pub fn set_text<T>(mut self, v: T) -> Self
362    where
363        T: std::convert::Into<crate::model::TextSpan>,
364    {
365        self.text = std::option::Option::Some(v.into());
366        self
367    }
368
369    /// Sets or clears the value of [text][crate::model::Sentence::text].
370    ///
371    /// # Example
372    /// ```ignore,no_run
373    /// # use google_cloud_language_v2::model::Sentence;
374    /// use google_cloud_language_v2::model::TextSpan;
375    /// let x = Sentence::new().set_or_clear_text(Some(TextSpan::default()/* use setters */));
376    /// let x = Sentence::new().set_or_clear_text(None::<TextSpan>);
377    /// ```
378    pub fn set_or_clear_text<T>(mut self, v: std::option::Option<T>) -> Self
379    where
380        T: std::convert::Into<crate::model::TextSpan>,
381    {
382        self.text = v.map(|x| x.into());
383        self
384    }
385
386    /// Sets the value of [sentiment][crate::model::Sentence::sentiment].
387    ///
388    /// # Example
389    /// ```ignore,no_run
390    /// # use google_cloud_language_v2::model::Sentence;
391    /// use google_cloud_language_v2::model::Sentiment;
392    /// let x = Sentence::new().set_sentiment(Sentiment::default()/* use setters */);
393    /// ```
394    pub fn set_sentiment<T>(mut self, v: T) -> Self
395    where
396        T: std::convert::Into<crate::model::Sentiment>,
397    {
398        self.sentiment = std::option::Option::Some(v.into());
399        self
400    }
401
402    /// Sets or clears the value of [sentiment][crate::model::Sentence::sentiment].
403    ///
404    /// # Example
405    /// ```ignore,no_run
406    /// # use google_cloud_language_v2::model::Sentence;
407    /// use google_cloud_language_v2::model::Sentiment;
408    /// let x = Sentence::new().set_or_clear_sentiment(Some(Sentiment::default()/* use setters */));
409    /// let x = Sentence::new().set_or_clear_sentiment(None::<Sentiment>);
410    /// ```
411    pub fn set_or_clear_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
412    where
413        T: std::convert::Into<crate::model::Sentiment>,
414    {
415        self.sentiment = v.map(|x| x.into());
416        self
417    }
418}
419
420impl wkt::message::Message for Sentence {
421    fn typename() -> &'static str {
422        "type.googleapis.com/google.cloud.language.v2.Sentence"
423    }
424}
425
426/// Represents a phrase in the text that is a known entity, such as
427/// a person, an organization, or location. The API associates information, such
428/// as probability and mentions, with entities.
429#[derive(Clone, Default, PartialEq)]
430#[non_exhaustive]
431pub struct Entity {
432    /// The representative name for the entity.
433    pub name: std::string::String,
434
435    /// The entity type.
436    pub r#type: crate::model::entity::Type,
437
438    /// Metadata associated with the entity.
439    ///
440    /// For the metadata
441    /// associated with other entity types, see the Type table below.
442    pub metadata: std::collections::HashMap<std::string::String, std::string::String>,
443
444    /// The mentions of this entity in the input document. The API currently
445    /// supports proper noun mentions.
446    pub mentions: std::vec::Vec<crate::model::EntityMention>,
447
448    /// For calls to [AnalyzeEntitySentiment][] or if
449    /// [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entity_sentiment]
450    /// is set to true, this field will contain the aggregate sentiment expressed
451    /// for this entity in the provided document.
452    pub sentiment: std::option::Option<crate::model::Sentiment>,
453
454    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
455}
456
457impl Entity {
458    pub fn new() -> Self {
459        std::default::Default::default()
460    }
461
462    /// Sets the value of [name][crate::model::Entity::name].
463    ///
464    /// # Example
465    /// ```ignore,no_run
466    /// # use google_cloud_language_v2::model::Entity;
467    /// let x = Entity::new().set_name("example");
468    /// ```
469    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
470        self.name = v.into();
471        self
472    }
473
474    /// Sets the value of [r#type][crate::model::Entity::type].
475    ///
476    /// # Example
477    /// ```ignore,no_run
478    /// # use google_cloud_language_v2::model::Entity;
479    /// use google_cloud_language_v2::model::entity::Type;
480    /// let x0 = Entity::new().set_type(Type::Person);
481    /// let x1 = Entity::new().set_type(Type::Location);
482    /// let x2 = Entity::new().set_type(Type::Organization);
483    /// ```
484    pub fn set_type<T: std::convert::Into<crate::model::entity::Type>>(mut self, v: T) -> Self {
485        self.r#type = v.into();
486        self
487    }
488
489    /// Sets the value of [metadata][crate::model::Entity::metadata].
490    ///
491    /// # Example
492    /// ```ignore,no_run
493    /// # use google_cloud_language_v2::model::Entity;
494    /// let x = Entity::new().set_metadata([
495    ///     ("key0", "abc"),
496    ///     ("key1", "xyz"),
497    /// ]);
498    /// ```
499    pub fn set_metadata<T, K, V>(mut self, v: T) -> Self
500    where
501        T: std::iter::IntoIterator<Item = (K, V)>,
502        K: std::convert::Into<std::string::String>,
503        V: std::convert::Into<std::string::String>,
504    {
505        use std::iter::Iterator;
506        self.metadata = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
507        self
508    }
509
510    /// Sets the value of [mentions][crate::model::Entity::mentions].
511    ///
512    /// # Example
513    /// ```ignore,no_run
514    /// # use google_cloud_language_v2::model::Entity;
515    /// use google_cloud_language_v2::model::EntityMention;
516    /// let x = Entity::new()
517    ///     .set_mentions([
518    ///         EntityMention::default()/* use setters */,
519    ///         EntityMention::default()/* use (different) setters */,
520    ///     ]);
521    /// ```
522    pub fn set_mentions<T, V>(mut self, v: T) -> Self
523    where
524        T: std::iter::IntoIterator<Item = V>,
525        V: std::convert::Into<crate::model::EntityMention>,
526    {
527        use std::iter::Iterator;
528        self.mentions = v.into_iter().map(|i| i.into()).collect();
529        self
530    }
531
532    /// Sets the value of [sentiment][crate::model::Entity::sentiment].
533    ///
534    /// # Example
535    /// ```ignore,no_run
536    /// # use google_cloud_language_v2::model::Entity;
537    /// use google_cloud_language_v2::model::Sentiment;
538    /// let x = Entity::new().set_sentiment(Sentiment::default()/* use setters */);
539    /// ```
540    pub fn set_sentiment<T>(mut self, v: T) -> Self
541    where
542        T: std::convert::Into<crate::model::Sentiment>,
543    {
544        self.sentiment = std::option::Option::Some(v.into());
545        self
546    }
547
548    /// Sets or clears the value of [sentiment][crate::model::Entity::sentiment].
549    ///
550    /// # Example
551    /// ```ignore,no_run
552    /// # use google_cloud_language_v2::model::Entity;
553    /// use google_cloud_language_v2::model::Sentiment;
554    /// let x = Entity::new().set_or_clear_sentiment(Some(Sentiment::default()/* use setters */));
555    /// let x = Entity::new().set_or_clear_sentiment(None::<Sentiment>);
556    /// ```
557    pub fn set_or_clear_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
558    where
559        T: std::convert::Into<crate::model::Sentiment>,
560    {
561        self.sentiment = v.map(|x| x.into());
562        self
563    }
564}
565
566impl wkt::message::Message for Entity {
567    fn typename() -> &'static str {
568        "type.googleapis.com/google.cloud.language.v2.Entity"
569    }
570}
571
572/// Defines additional types related to [Entity].
573pub mod entity {
574    #[allow(unused_imports)]
575    use super::*;
576
577    /// The type of the entity. The table
578    /// below lists the associated fields for entities that have different
579    /// metadata.
580    ///
581    /// # Working with unknown values
582    ///
583    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
584    /// additional enum variants at any time. Adding new variants is not considered
585    /// a breaking change. Applications should write their code in anticipation of:
586    ///
587    /// - New values appearing in future releases of the client library, **and**
588    /// - New values received dynamically, without application changes.
589    ///
590    /// Please consult the [Working with enums] section in the user guide for some
591    /// guidelines.
592    ///
593    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
594    #[derive(Clone, Debug, PartialEq)]
595    #[non_exhaustive]
596    pub enum Type {
597        /// Unknown
598        Unknown,
599        /// Person
600        Person,
601        /// Location
602        Location,
603        /// Organization
604        Organization,
605        /// Event
606        Event,
607        /// Artwork
608        WorkOfArt,
609        /// Consumer product
610        ConsumerGood,
611        /// Other types of entities
612        Other,
613        /// Phone number
614        ///
615        /// The metadata lists the phone number, formatted according to local
616        /// convention, plus whichever additional elements appear in the text:
617        ///
618        /// * `number` - the actual number, broken down into sections as per local
619        ///   convention
620        /// * `national_prefix` - country code, if detected
621        /// * `area_code` - region or area code, if detected
622        /// * `extension` - phone extension (to be dialed after connection), if
623        ///   detected
624        PhoneNumber,
625        /// Address
626        ///
627        /// The metadata identifies the street number and locality plus whichever
628        /// additional elements appear in the text:
629        ///
630        /// * `street_number` - street number
631        /// * `locality` - city or town
632        /// * `street_name` - street/route name, if detected
633        /// * `postal_code` - postal code, if detected
634        /// * `country` - country, if detected
635        /// * `broad_region` - administrative area, such as the state, if detected
636        /// * `narrow_region` - smaller administrative area, such as county, if
637        ///   detected
638        /// * `sublocality` - used in Asian addresses to demark a district within a
639        ///   city, if detected
640        Address,
641        /// Date
642        ///
643        /// The metadata identifies the components of the date:
644        ///
645        /// * `year` - four digit year, if detected
646        /// * `month` - two digit month number, if detected
647        /// * `day` - two digit day number, if detected
648        Date,
649        /// Number
650        ///
651        /// The metadata is the number itself.
652        Number,
653        /// Price
654        ///
655        /// The metadata identifies the `value` and `currency`.
656        Price,
657        /// If set, the enum was initialized with an unknown value.
658        ///
659        /// Applications can examine the value using [Type::value] or
660        /// [Type::name].
661        UnknownValue(r#type::UnknownValue),
662    }
663
664    #[doc(hidden)]
665    pub mod r#type {
666        #[allow(unused_imports)]
667        use super::*;
668        #[derive(Clone, Debug, PartialEq)]
669        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
670    }
671
672    impl Type {
673        /// Gets the enum value.
674        ///
675        /// Returns `None` if the enum contains an unknown value deserialized from
676        /// the string representation of enums.
677        pub fn value(&self) -> std::option::Option<i32> {
678            match self {
679                Self::Unknown => std::option::Option::Some(0),
680                Self::Person => std::option::Option::Some(1),
681                Self::Location => std::option::Option::Some(2),
682                Self::Organization => std::option::Option::Some(3),
683                Self::Event => std::option::Option::Some(4),
684                Self::WorkOfArt => std::option::Option::Some(5),
685                Self::ConsumerGood => std::option::Option::Some(6),
686                Self::Other => std::option::Option::Some(7),
687                Self::PhoneNumber => std::option::Option::Some(9),
688                Self::Address => std::option::Option::Some(10),
689                Self::Date => std::option::Option::Some(11),
690                Self::Number => std::option::Option::Some(12),
691                Self::Price => std::option::Option::Some(13),
692                Self::UnknownValue(u) => u.0.value(),
693            }
694        }
695
696        /// Gets the enum value as a string.
697        ///
698        /// Returns `None` if the enum contains an unknown value deserialized from
699        /// the integer representation of enums.
700        pub fn name(&self) -> std::option::Option<&str> {
701            match self {
702                Self::Unknown => std::option::Option::Some("UNKNOWN"),
703                Self::Person => std::option::Option::Some("PERSON"),
704                Self::Location => std::option::Option::Some("LOCATION"),
705                Self::Organization => std::option::Option::Some("ORGANIZATION"),
706                Self::Event => std::option::Option::Some("EVENT"),
707                Self::WorkOfArt => std::option::Option::Some("WORK_OF_ART"),
708                Self::ConsumerGood => std::option::Option::Some("CONSUMER_GOOD"),
709                Self::Other => std::option::Option::Some("OTHER"),
710                Self::PhoneNumber => std::option::Option::Some("PHONE_NUMBER"),
711                Self::Address => std::option::Option::Some("ADDRESS"),
712                Self::Date => std::option::Option::Some("DATE"),
713                Self::Number => std::option::Option::Some("NUMBER"),
714                Self::Price => std::option::Option::Some("PRICE"),
715                Self::UnknownValue(u) => u.0.name(),
716            }
717        }
718    }
719
720    impl std::default::Default for Type {
721        fn default() -> Self {
722            use std::convert::From;
723            Self::from(0)
724        }
725    }
726
727    impl std::fmt::Display for Type {
728        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
729            wkt::internal::display_enum(f, self.name(), self.value())
730        }
731    }
732
733    impl std::convert::From<i32> for Type {
734        fn from(value: i32) -> Self {
735            match value {
736                0 => Self::Unknown,
737                1 => Self::Person,
738                2 => Self::Location,
739                3 => Self::Organization,
740                4 => Self::Event,
741                5 => Self::WorkOfArt,
742                6 => Self::ConsumerGood,
743                7 => Self::Other,
744                9 => Self::PhoneNumber,
745                10 => Self::Address,
746                11 => Self::Date,
747                12 => Self::Number,
748                13 => Self::Price,
749                _ => Self::UnknownValue(r#type::UnknownValue(
750                    wkt::internal::UnknownEnumValue::Integer(value),
751                )),
752            }
753        }
754    }
755
756    impl std::convert::From<&str> for Type {
757        fn from(value: &str) -> Self {
758            use std::string::ToString;
759            match value {
760                "UNKNOWN" => Self::Unknown,
761                "PERSON" => Self::Person,
762                "LOCATION" => Self::Location,
763                "ORGANIZATION" => Self::Organization,
764                "EVENT" => Self::Event,
765                "WORK_OF_ART" => Self::WorkOfArt,
766                "CONSUMER_GOOD" => Self::ConsumerGood,
767                "OTHER" => Self::Other,
768                "PHONE_NUMBER" => Self::PhoneNumber,
769                "ADDRESS" => Self::Address,
770                "DATE" => Self::Date,
771                "NUMBER" => Self::Number,
772                "PRICE" => Self::Price,
773                _ => Self::UnknownValue(r#type::UnknownValue(
774                    wkt::internal::UnknownEnumValue::String(value.to_string()),
775                )),
776            }
777        }
778    }
779
780    impl serde::ser::Serialize for Type {
781        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
782        where
783            S: serde::Serializer,
784        {
785            match self {
786                Self::Unknown => serializer.serialize_i32(0),
787                Self::Person => serializer.serialize_i32(1),
788                Self::Location => serializer.serialize_i32(2),
789                Self::Organization => serializer.serialize_i32(3),
790                Self::Event => serializer.serialize_i32(4),
791                Self::WorkOfArt => serializer.serialize_i32(5),
792                Self::ConsumerGood => serializer.serialize_i32(6),
793                Self::Other => serializer.serialize_i32(7),
794                Self::PhoneNumber => serializer.serialize_i32(9),
795                Self::Address => serializer.serialize_i32(10),
796                Self::Date => serializer.serialize_i32(11),
797                Self::Number => serializer.serialize_i32(12),
798                Self::Price => serializer.serialize_i32(13),
799                Self::UnknownValue(u) => u.0.serialize(serializer),
800            }
801        }
802    }
803
804    impl<'de> serde::de::Deserialize<'de> for Type {
805        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
806        where
807            D: serde::Deserializer<'de>,
808        {
809            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
810                ".google.cloud.language.v2.Entity.Type",
811            ))
812        }
813    }
814}
815
816/// Represents the feeling associated with the entire text or entities in
817/// the text.
818#[derive(Clone, Default, PartialEq)]
819#[non_exhaustive]
820pub struct Sentiment {
821    /// A non-negative number in the [0, +inf) range, which represents
822    /// the absolute magnitude of sentiment regardless of score (positive or
823    /// negative).
824    pub magnitude: f32,
825
826    /// Sentiment score between -1.0 (negative sentiment) and 1.0
827    /// (positive sentiment).
828    pub score: f32,
829
830    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
831}
832
833impl Sentiment {
834    pub fn new() -> Self {
835        std::default::Default::default()
836    }
837
838    /// Sets the value of [magnitude][crate::model::Sentiment::magnitude].
839    ///
840    /// # Example
841    /// ```ignore,no_run
842    /// # use google_cloud_language_v2::model::Sentiment;
843    /// let x = Sentiment::new().set_magnitude(42.0);
844    /// ```
845    pub fn set_magnitude<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
846        self.magnitude = v.into();
847        self
848    }
849
850    /// Sets the value of [score][crate::model::Sentiment::score].
851    ///
852    /// # Example
853    /// ```ignore,no_run
854    /// # use google_cloud_language_v2::model::Sentiment;
855    /// let x = Sentiment::new().set_score(42.0);
856    /// ```
857    pub fn set_score<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
858        self.score = v.into();
859        self
860    }
861}
862
863impl wkt::message::Message for Sentiment {
864    fn typename() -> &'static str {
865        "type.googleapis.com/google.cloud.language.v2.Sentiment"
866    }
867}
868
869/// Represents a mention for an entity in the text. Currently, proper noun
870/// mentions are supported.
871#[derive(Clone, Default, PartialEq)]
872#[non_exhaustive]
873pub struct EntityMention {
874    /// The mention text.
875    pub text: std::option::Option<crate::model::TextSpan>,
876
877    /// The type of the entity mention.
878    pub r#type: crate::model::entity_mention::Type,
879
880    /// For calls to [AnalyzeEntitySentiment][] or if
881    /// [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entity_sentiment]
882    /// is set to true, this field will contain the sentiment expressed for this
883    /// mention of the entity in the provided document.
884    pub sentiment: std::option::Option<crate::model::Sentiment>,
885
886    /// Probability score associated with the entity.
887    ///
888    /// The score shows the probability of the entity mention being the entity
889    /// type. The score is in (0, 1] range.
890    pub probability: f32,
891
892    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
893}
894
895impl EntityMention {
896    pub fn new() -> Self {
897        std::default::Default::default()
898    }
899
900    /// Sets the value of [text][crate::model::EntityMention::text].
901    ///
902    /// # Example
903    /// ```ignore,no_run
904    /// # use google_cloud_language_v2::model::EntityMention;
905    /// use google_cloud_language_v2::model::TextSpan;
906    /// let x = EntityMention::new().set_text(TextSpan::default()/* use setters */);
907    /// ```
908    pub fn set_text<T>(mut self, v: T) -> Self
909    where
910        T: std::convert::Into<crate::model::TextSpan>,
911    {
912        self.text = std::option::Option::Some(v.into());
913        self
914    }
915
916    /// Sets or clears the value of [text][crate::model::EntityMention::text].
917    ///
918    /// # Example
919    /// ```ignore,no_run
920    /// # use google_cloud_language_v2::model::EntityMention;
921    /// use google_cloud_language_v2::model::TextSpan;
922    /// let x = EntityMention::new().set_or_clear_text(Some(TextSpan::default()/* use setters */));
923    /// let x = EntityMention::new().set_or_clear_text(None::<TextSpan>);
924    /// ```
925    pub fn set_or_clear_text<T>(mut self, v: std::option::Option<T>) -> Self
926    where
927        T: std::convert::Into<crate::model::TextSpan>,
928    {
929        self.text = v.map(|x| x.into());
930        self
931    }
932
933    /// Sets the value of [r#type][crate::model::EntityMention::type].
934    ///
935    /// # Example
936    /// ```ignore,no_run
937    /// # use google_cloud_language_v2::model::EntityMention;
938    /// use google_cloud_language_v2::model::entity_mention::Type;
939    /// let x0 = EntityMention::new().set_type(Type::Proper);
940    /// let x1 = EntityMention::new().set_type(Type::Common);
941    /// ```
942    pub fn set_type<T: std::convert::Into<crate::model::entity_mention::Type>>(
943        mut self,
944        v: T,
945    ) -> Self {
946        self.r#type = v.into();
947        self
948    }
949
950    /// Sets the value of [sentiment][crate::model::EntityMention::sentiment].
951    ///
952    /// # Example
953    /// ```ignore,no_run
954    /// # use google_cloud_language_v2::model::EntityMention;
955    /// use google_cloud_language_v2::model::Sentiment;
956    /// let x = EntityMention::new().set_sentiment(Sentiment::default()/* use setters */);
957    /// ```
958    pub fn set_sentiment<T>(mut self, v: T) -> Self
959    where
960        T: std::convert::Into<crate::model::Sentiment>,
961    {
962        self.sentiment = std::option::Option::Some(v.into());
963        self
964    }
965
966    /// Sets or clears the value of [sentiment][crate::model::EntityMention::sentiment].
967    ///
968    /// # Example
969    /// ```ignore,no_run
970    /// # use google_cloud_language_v2::model::EntityMention;
971    /// use google_cloud_language_v2::model::Sentiment;
972    /// let x = EntityMention::new().set_or_clear_sentiment(Some(Sentiment::default()/* use setters */));
973    /// let x = EntityMention::new().set_or_clear_sentiment(None::<Sentiment>);
974    /// ```
975    pub fn set_or_clear_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
976    where
977        T: std::convert::Into<crate::model::Sentiment>,
978    {
979        self.sentiment = v.map(|x| x.into());
980        self
981    }
982
983    /// Sets the value of [probability][crate::model::EntityMention::probability].
984    ///
985    /// # Example
986    /// ```ignore,no_run
987    /// # use google_cloud_language_v2::model::EntityMention;
988    /// let x = EntityMention::new().set_probability(42.0);
989    /// ```
990    pub fn set_probability<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
991        self.probability = v.into();
992        self
993    }
994}
995
996impl wkt::message::Message for EntityMention {
997    fn typename() -> &'static str {
998        "type.googleapis.com/google.cloud.language.v2.EntityMention"
999    }
1000}
1001
1002/// Defines additional types related to [EntityMention].
1003pub mod entity_mention {
1004    #[allow(unused_imports)]
1005    use super::*;
1006
1007    /// The supported types of mentions.
1008    ///
1009    /// # Working with unknown values
1010    ///
1011    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1012    /// additional enum variants at any time. Adding new variants is not considered
1013    /// a breaking change. Applications should write their code in anticipation of:
1014    ///
1015    /// - New values appearing in future releases of the client library, **and**
1016    /// - New values received dynamically, without application changes.
1017    ///
1018    /// Please consult the [Working with enums] section in the user guide for some
1019    /// guidelines.
1020    ///
1021    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1022    #[derive(Clone, Debug, PartialEq)]
1023    #[non_exhaustive]
1024    pub enum Type {
1025        /// Unknown
1026        Unknown,
1027        /// Proper name
1028        Proper,
1029        /// Common noun (or noun compound)
1030        Common,
1031        /// If set, the enum was initialized with an unknown value.
1032        ///
1033        /// Applications can examine the value using [Type::value] or
1034        /// [Type::name].
1035        UnknownValue(r#type::UnknownValue),
1036    }
1037
1038    #[doc(hidden)]
1039    pub mod r#type {
1040        #[allow(unused_imports)]
1041        use super::*;
1042        #[derive(Clone, Debug, PartialEq)]
1043        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1044    }
1045
1046    impl Type {
1047        /// Gets the enum value.
1048        ///
1049        /// Returns `None` if the enum contains an unknown value deserialized from
1050        /// the string representation of enums.
1051        pub fn value(&self) -> std::option::Option<i32> {
1052            match self {
1053                Self::Unknown => std::option::Option::Some(0),
1054                Self::Proper => std::option::Option::Some(1),
1055                Self::Common => std::option::Option::Some(2),
1056                Self::UnknownValue(u) => u.0.value(),
1057            }
1058        }
1059
1060        /// Gets the enum value as a string.
1061        ///
1062        /// Returns `None` if the enum contains an unknown value deserialized from
1063        /// the integer representation of enums.
1064        pub fn name(&self) -> std::option::Option<&str> {
1065            match self {
1066                Self::Unknown => std::option::Option::Some("TYPE_UNKNOWN"),
1067                Self::Proper => std::option::Option::Some("PROPER"),
1068                Self::Common => std::option::Option::Some("COMMON"),
1069                Self::UnknownValue(u) => u.0.name(),
1070            }
1071        }
1072    }
1073
1074    impl std::default::Default for Type {
1075        fn default() -> Self {
1076            use std::convert::From;
1077            Self::from(0)
1078        }
1079    }
1080
1081    impl std::fmt::Display for Type {
1082        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1083            wkt::internal::display_enum(f, self.name(), self.value())
1084        }
1085    }
1086
1087    impl std::convert::From<i32> for Type {
1088        fn from(value: i32) -> Self {
1089            match value {
1090                0 => Self::Unknown,
1091                1 => Self::Proper,
1092                2 => Self::Common,
1093                _ => Self::UnknownValue(r#type::UnknownValue(
1094                    wkt::internal::UnknownEnumValue::Integer(value),
1095                )),
1096            }
1097        }
1098    }
1099
1100    impl std::convert::From<&str> for Type {
1101        fn from(value: &str) -> Self {
1102            use std::string::ToString;
1103            match value {
1104                "TYPE_UNKNOWN" => Self::Unknown,
1105                "PROPER" => Self::Proper,
1106                "COMMON" => Self::Common,
1107                _ => Self::UnknownValue(r#type::UnknownValue(
1108                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1109                )),
1110            }
1111        }
1112    }
1113
1114    impl serde::ser::Serialize for Type {
1115        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1116        where
1117            S: serde::Serializer,
1118        {
1119            match self {
1120                Self::Unknown => serializer.serialize_i32(0),
1121                Self::Proper => serializer.serialize_i32(1),
1122                Self::Common => serializer.serialize_i32(2),
1123                Self::UnknownValue(u) => u.0.serialize(serializer),
1124            }
1125        }
1126    }
1127
1128    impl<'de> serde::de::Deserialize<'de> for Type {
1129        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1130        where
1131            D: serde::Deserializer<'de>,
1132        {
1133            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
1134                ".google.cloud.language.v2.EntityMention.Type",
1135            ))
1136        }
1137    }
1138}
1139
1140/// Represents a text span in the input document.
1141#[derive(Clone, Default, PartialEq)]
1142#[non_exhaustive]
1143pub struct TextSpan {
1144    /// The content of the text span, which is a substring of the document.
1145    pub content: std::string::String,
1146
1147    /// The API calculates the beginning offset of the content in the original
1148    /// document according to the
1149    /// [EncodingType][google.cloud.language.v2.EncodingType] specified in the API
1150    /// request.
1151    ///
1152    /// [google.cloud.language.v2.EncodingType]: crate::model::EncodingType
1153    pub begin_offset: i32,
1154
1155    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1156}
1157
1158impl TextSpan {
1159    pub fn new() -> Self {
1160        std::default::Default::default()
1161    }
1162
1163    /// Sets the value of [content][crate::model::TextSpan::content].
1164    ///
1165    /// # Example
1166    /// ```ignore,no_run
1167    /// # use google_cloud_language_v2::model::TextSpan;
1168    /// let x = TextSpan::new().set_content("example");
1169    /// ```
1170    pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1171        self.content = v.into();
1172        self
1173    }
1174
1175    /// Sets the value of [begin_offset][crate::model::TextSpan::begin_offset].
1176    ///
1177    /// # Example
1178    /// ```ignore,no_run
1179    /// # use google_cloud_language_v2::model::TextSpan;
1180    /// let x = TextSpan::new().set_begin_offset(42);
1181    /// ```
1182    pub fn set_begin_offset<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1183        self.begin_offset = v.into();
1184        self
1185    }
1186}
1187
1188impl wkt::message::Message for TextSpan {
1189    fn typename() -> &'static str {
1190        "type.googleapis.com/google.cloud.language.v2.TextSpan"
1191    }
1192}
1193
1194/// Represents a category returned from the text classifier.
1195#[derive(Clone, Default, PartialEq)]
1196#[non_exhaustive]
1197pub struct ClassificationCategory {
1198    /// The name of the category representing the document.
1199    pub name: std::string::String,
1200
1201    /// The classifier's confidence of the category. Number represents how certain
1202    /// the classifier is that this category represents the given text.
1203    pub confidence: f32,
1204
1205    /// Optional. The classifier's severity of the category. This is only present
1206    /// when the ModerateTextRequest.ModelVersion is set to MODEL_VERSION_2, and
1207    /// the corresponding category has a severity score.
1208    pub severity: f32,
1209
1210    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1211}
1212
1213impl ClassificationCategory {
1214    pub fn new() -> Self {
1215        std::default::Default::default()
1216    }
1217
1218    /// Sets the value of [name][crate::model::ClassificationCategory::name].
1219    ///
1220    /// # Example
1221    /// ```ignore,no_run
1222    /// # use google_cloud_language_v2::model::ClassificationCategory;
1223    /// let x = ClassificationCategory::new().set_name("example");
1224    /// ```
1225    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1226        self.name = v.into();
1227        self
1228    }
1229
1230    /// Sets the value of [confidence][crate::model::ClassificationCategory::confidence].
1231    ///
1232    /// # Example
1233    /// ```ignore,no_run
1234    /// # use google_cloud_language_v2::model::ClassificationCategory;
1235    /// let x = ClassificationCategory::new().set_confidence(42.0);
1236    /// ```
1237    pub fn set_confidence<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
1238        self.confidence = v.into();
1239        self
1240    }
1241
1242    /// Sets the value of [severity][crate::model::ClassificationCategory::severity].
1243    ///
1244    /// # Example
1245    /// ```ignore,no_run
1246    /// # use google_cloud_language_v2::model::ClassificationCategory;
1247    /// let x = ClassificationCategory::new().set_severity(42.0);
1248    /// ```
1249    pub fn set_severity<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
1250        self.severity = v.into();
1251        self
1252    }
1253}
1254
1255impl wkt::message::Message for ClassificationCategory {
1256    fn typename() -> &'static str {
1257        "type.googleapis.com/google.cloud.language.v2.ClassificationCategory"
1258    }
1259}
1260
1261/// The sentiment analysis request message.
1262#[derive(Clone, Default, PartialEq)]
1263#[non_exhaustive]
1264pub struct AnalyzeSentimentRequest {
1265    /// Required. Input document.
1266    pub document: std::option::Option<crate::model::Document>,
1267
1268    /// The encoding type used by the API to calculate sentence offsets.
1269    pub encoding_type: crate::model::EncodingType,
1270
1271    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1272}
1273
1274impl AnalyzeSentimentRequest {
1275    pub fn new() -> Self {
1276        std::default::Default::default()
1277    }
1278
1279    /// Sets the value of [document][crate::model::AnalyzeSentimentRequest::document].
1280    ///
1281    /// # Example
1282    /// ```ignore,no_run
1283    /// # use google_cloud_language_v2::model::AnalyzeSentimentRequest;
1284    /// use google_cloud_language_v2::model::Document;
1285    /// let x = AnalyzeSentimentRequest::new().set_document(Document::default()/* use setters */);
1286    /// ```
1287    pub fn set_document<T>(mut self, v: T) -> Self
1288    where
1289        T: std::convert::Into<crate::model::Document>,
1290    {
1291        self.document = std::option::Option::Some(v.into());
1292        self
1293    }
1294
1295    /// Sets or clears the value of [document][crate::model::AnalyzeSentimentRequest::document].
1296    ///
1297    /// # Example
1298    /// ```ignore,no_run
1299    /// # use google_cloud_language_v2::model::AnalyzeSentimentRequest;
1300    /// use google_cloud_language_v2::model::Document;
1301    /// let x = AnalyzeSentimentRequest::new().set_or_clear_document(Some(Document::default()/* use setters */));
1302    /// let x = AnalyzeSentimentRequest::new().set_or_clear_document(None::<Document>);
1303    /// ```
1304    pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1305    where
1306        T: std::convert::Into<crate::model::Document>,
1307    {
1308        self.document = v.map(|x| x.into());
1309        self
1310    }
1311
1312    /// Sets the value of [encoding_type][crate::model::AnalyzeSentimentRequest::encoding_type].
1313    ///
1314    /// # Example
1315    /// ```ignore,no_run
1316    /// # use google_cloud_language_v2::model::AnalyzeSentimentRequest;
1317    /// use google_cloud_language_v2::model::EncodingType;
1318    /// let x0 = AnalyzeSentimentRequest::new().set_encoding_type(EncodingType::Utf8);
1319    /// let x1 = AnalyzeSentimentRequest::new().set_encoding_type(EncodingType::Utf16);
1320    /// let x2 = AnalyzeSentimentRequest::new().set_encoding_type(EncodingType::Utf32);
1321    /// ```
1322    pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
1323        mut self,
1324        v: T,
1325    ) -> Self {
1326        self.encoding_type = v.into();
1327        self
1328    }
1329}
1330
1331impl wkt::message::Message for AnalyzeSentimentRequest {
1332    fn typename() -> &'static str {
1333        "type.googleapis.com/google.cloud.language.v2.AnalyzeSentimentRequest"
1334    }
1335}
1336
1337/// The sentiment analysis response message.
1338#[derive(Clone, Default, PartialEq)]
1339#[non_exhaustive]
1340pub struct AnalyzeSentimentResponse {
1341    /// The overall sentiment of the input document.
1342    pub document_sentiment: std::option::Option<crate::model::Sentiment>,
1343
1344    /// The language of the text, which will be the same as the language specified
1345    /// in the request or, if not specified, the automatically-detected language.
1346    /// See [Document.language][] field for more details.
1347    pub language_code: std::string::String,
1348
1349    /// The sentiment for all the sentences in the document.
1350    pub sentences: std::vec::Vec<crate::model::Sentence>,
1351
1352    /// Whether the language is officially supported. The API may still return a
1353    /// response when the language is not supported, but it is on a best effort
1354    /// basis.
1355    pub language_supported: bool,
1356
1357    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1358}
1359
1360impl AnalyzeSentimentResponse {
1361    pub fn new() -> Self {
1362        std::default::Default::default()
1363    }
1364
1365    /// Sets the value of [document_sentiment][crate::model::AnalyzeSentimentResponse::document_sentiment].
1366    ///
1367    /// # Example
1368    /// ```ignore,no_run
1369    /// # use google_cloud_language_v2::model::AnalyzeSentimentResponse;
1370    /// use google_cloud_language_v2::model::Sentiment;
1371    /// let x = AnalyzeSentimentResponse::new().set_document_sentiment(Sentiment::default()/* use setters */);
1372    /// ```
1373    pub fn set_document_sentiment<T>(mut self, v: T) -> Self
1374    where
1375        T: std::convert::Into<crate::model::Sentiment>,
1376    {
1377        self.document_sentiment = std::option::Option::Some(v.into());
1378        self
1379    }
1380
1381    /// Sets or clears the value of [document_sentiment][crate::model::AnalyzeSentimentResponse::document_sentiment].
1382    ///
1383    /// # Example
1384    /// ```ignore,no_run
1385    /// # use google_cloud_language_v2::model::AnalyzeSentimentResponse;
1386    /// use google_cloud_language_v2::model::Sentiment;
1387    /// let x = AnalyzeSentimentResponse::new().set_or_clear_document_sentiment(Some(Sentiment::default()/* use setters */));
1388    /// let x = AnalyzeSentimentResponse::new().set_or_clear_document_sentiment(None::<Sentiment>);
1389    /// ```
1390    pub fn set_or_clear_document_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
1391    where
1392        T: std::convert::Into<crate::model::Sentiment>,
1393    {
1394        self.document_sentiment = v.map(|x| x.into());
1395        self
1396    }
1397
1398    /// Sets the value of [language_code][crate::model::AnalyzeSentimentResponse::language_code].
1399    ///
1400    /// # Example
1401    /// ```ignore,no_run
1402    /// # use google_cloud_language_v2::model::AnalyzeSentimentResponse;
1403    /// let x = AnalyzeSentimentResponse::new().set_language_code("example");
1404    /// ```
1405    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1406        self.language_code = v.into();
1407        self
1408    }
1409
1410    /// Sets the value of [sentences][crate::model::AnalyzeSentimentResponse::sentences].
1411    ///
1412    /// # Example
1413    /// ```ignore,no_run
1414    /// # use google_cloud_language_v2::model::AnalyzeSentimentResponse;
1415    /// use google_cloud_language_v2::model::Sentence;
1416    /// let x = AnalyzeSentimentResponse::new()
1417    ///     .set_sentences([
1418    ///         Sentence::default()/* use setters */,
1419    ///         Sentence::default()/* use (different) setters */,
1420    ///     ]);
1421    /// ```
1422    pub fn set_sentences<T, V>(mut self, v: T) -> Self
1423    where
1424        T: std::iter::IntoIterator<Item = V>,
1425        V: std::convert::Into<crate::model::Sentence>,
1426    {
1427        use std::iter::Iterator;
1428        self.sentences = v.into_iter().map(|i| i.into()).collect();
1429        self
1430    }
1431
1432    /// Sets the value of [language_supported][crate::model::AnalyzeSentimentResponse::language_supported].
1433    ///
1434    /// # Example
1435    /// ```ignore,no_run
1436    /// # use google_cloud_language_v2::model::AnalyzeSentimentResponse;
1437    /// let x = AnalyzeSentimentResponse::new().set_language_supported(true);
1438    /// ```
1439    pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1440        self.language_supported = v.into();
1441        self
1442    }
1443}
1444
1445impl wkt::message::Message for AnalyzeSentimentResponse {
1446    fn typename() -> &'static str {
1447        "type.googleapis.com/google.cloud.language.v2.AnalyzeSentimentResponse"
1448    }
1449}
1450
1451/// The entity analysis request message.
1452#[derive(Clone, Default, PartialEq)]
1453#[non_exhaustive]
1454pub struct AnalyzeEntitiesRequest {
1455    /// Required. Input document.
1456    pub document: std::option::Option<crate::model::Document>,
1457
1458    /// The encoding type used by the API to calculate offsets.
1459    pub encoding_type: crate::model::EncodingType,
1460
1461    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1462}
1463
1464impl AnalyzeEntitiesRequest {
1465    pub fn new() -> Self {
1466        std::default::Default::default()
1467    }
1468
1469    /// Sets the value of [document][crate::model::AnalyzeEntitiesRequest::document].
1470    ///
1471    /// # Example
1472    /// ```ignore,no_run
1473    /// # use google_cloud_language_v2::model::AnalyzeEntitiesRequest;
1474    /// use google_cloud_language_v2::model::Document;
1475    /// let x = AnalyzeEntitiesRequest::new().set_document(Document::default()/* use setters */);
1476    /// ```
1477    pub fn set_document<T>(mut self, v: T) -> Self
1478    where
1479        T: std::convert::Into<crate::model::Document>,
1480    {
1481        self.document = std::option::Option::Some(v.into());
1482        self
1483    }
1484
1485    /// Sets or clears the value of [document][crate::model::AnalyzeEntitiesRequest::document].
1486    ///
1487    /// # Example
1488    /// ```ignore,no_run
1489    /// # use google_cloud_language_v2::model::AnalyzeEntitiesRequest;
1490    /// use google_cloud_language_v2::model::Document;
1491    /// let x = AnalyzeEntitiesRequest::new().set_or_clear_document(Some(Document::default()/* use setters */));
1492    /// let x = AnalyzeEntitiesRequest::new().set_or_clear_document(None::<Document>);
1493    /// ```
1494    pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1495    where
1496        T: std::convert::Into<crate::model::Document>,
1497    {
1498        self.document = v.map(|x| x.into());
1499        self
1500    }
1501
1502    /// Sets the value of [encoding_type][crate::model::AnalyzeEntitiesRequest::encoding_type].
1503    ///
1504    /// # Example
1505    /// ```ignore,no_run
1506    /// # use google_cloud_language_v2::model::AnalyzeEntitiesRequest;
1507    /// use google_cloud_language_v2::model::EncodingType;
1508    /// let x0 = AnalyzeEntitiesRequest::new().set_encoding_type(EncodingType::Utf8);
1509    /// let x1 = AnalyzeEntitiesRequest::new().set_encoding_type(EncodingType::Utf16);
1510    /// let x2 = AnalyzeEntitiesRequest::new().set_encoding_type(EncodingType::Utf32);
1511    /// ```
1512    pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
1513        mut self,
1514        v: T,
1515    ) -> Self {
1516        self.encoding_type = v.into();
1517        self
1518    }
1519}
1520
1521impl wkt::message::Message for AnalyzeEntitiesRequest {
1522    fn typename() -> &'static str {
1523        "type.googleapis.com/google.cloud.language.v2.AnalyzeEntitiesRequest"
1524    }
1525}
1526
1527/// The entity analysis response message.
1528#[derive(Clone, Default, PartialEq)]
1529#[non_exhaustive]
1530pub struct AnalyzeEntitiesResponse {
1531    /// The recognized entities in the input document.
1532    pub entities: std::vec::Vec<crate::model::Entity>,
1533
1534    /// The language of the text, which will be the same as the language specified
1535    /// in the request or, if not specified, the automatically-detected language.
1536    /// See [Document.language][] field for more details.
1537    pub language_code: std::string::String,
1538
1539    /// Whether the language is officially supported. The API may still return a
1540    /// response when the language is not supported, but it is on a best effort
1541    /// basis.
1542    pub language_supported: bool,
1543
1544    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1545}
1546
1547impl AnalyzeEntitiesResponse {
1548    pub fn new() -> Self {
1549        std::default::Default::default()
1550    }
1551
1552    /// Sets the value of [entities][crate::model::AnalyzeEntitiesResponse::entities].
1553    ///
1554    /// # Example
1555    /// ```ignore,no_run
1556    /// # use google_cloud_language_v2::model::AnalyzeEntitiesResponse;
1557    /// use google_cloud_language_v2::model::Entity;
1558    /// let x = AnalyzeEntitiesResponse::new()
1559    ///     .set_entities([
1560    ///         Entity::default()/* use setters */,
1561    ///         Entity::default()/* use (different) setters */,
1562    ///     ]);
1563    /// ```
1564    pub fn set_entities<T, V>(mut self, v: T) -> Self
1565    where
1566        T: std::iter::IntoIterator<Item = V>,
1567        V: std::convert::Into<crate::model::Entity>,
1568    {
1569        use std::iter::Iterator;
1570        self.entities = v.into_iter().map(|i| i.into()).collect();
1571        self
1572    }
1573
1574    /// Sets the value of [language_code][crate::model::AnalyzeEntitiesResponse::language_code].
1575    ///
1576    /// # Example
1577    /// ```ignore,no_run
1578    /// # use google_cloud_language_v2::model::AnalyzeEntitiesResponse;
1579    /// let x = AnalyzeEntitiesResponse::new().set_language_code("example");
1580    /// ```
1581    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1582        self.language_code = v.into();
1583        self
1584    }
1585
1586    /// Sets the value of [language_supported][crate::model::AnalyzeEntitiesResponse::language_supported].
1587    ///
1588    /// # Example
1589    /// ```ignore,no_run
1590    /// # use google_cloud_language_v2::model::AnalyzeEntitiesResponse;
1591    /// let x = AnalyzeEntitiesResponse::new().set_language_supported(true);
1592    /// ```
1593    pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1594        self.language_supported = v.into();
1595        self
1596    }
1597}
1598
1599impl wkt::message::Message for AnalyzeEntitiesResponse {
1600    fn typename() -> &'static str {
1601        "type.googleapis.com/google.cloud.language.v2.AnalyzeEntitiesResponse"
1602    }
1603}
1604
1605/// The document classification request message.
1606#[derive(Clone, Default, PartialEq)]
1607#[non_exhaustive]
1608pub struct ClassifyTextRequest {
1609    /// Required. Input document.
1610    pub document: std::option::Option<crate::model::Document>,
1611
1612    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1613}
1614
1615impl ClassifyTextRequest {
1616    pub fn new() -> Self {
1617        std::default::Default::default()
1618    }
1619
1620    /// Sets the value of [document][crate::model::ClassifyTextRequest::document].
1621    ///
1622    /// # Example
1623    /// ```ignore,no_run
1624    /// # use google_cloud_language_v2::model::ClassifyTextRequest;
1625    /// use google_cloud_language_v2::model::Document;
1626    /// let x = ClassifyTextRequest::new().set_document(Document::default()/* use setters */);
1627    /// ```
1628    pub fn set_document<T>(mut self, v: T) -> Self
1629    where
1630        T: std::convert::Into<crate::model::Document>,
1631    {
1632        self.document = std::option::Option::Some(v.into());
1633        self
1634    }
1635
1636    /// Sets or clears the value of [document][crate::model::ClassifyTextRequest::document].
1637    ///
1638    /// # Example
1639    /// ```ignore,no_run
1640    /// # use google_cloud_language_v2::model::ClassifyTextRequest;
1641    /// use google_cloud_language_v2::model::Document;
1642    /// let x = ClassifyTextRequest::new().set_or_clear_document(Some(Document::default()/* use setters */));
1643    /// let x = ClassifyTextRequest::new().set_or_clear_document(None::<Document>);
1644    /// ```
1645    pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1646    where
1647        T: std::convert::Into<crate::model::Document>,
1648    {
1649        self.document = v.map(|x| x.into());
1650        self
1651    }
1652}
1653
1654impl wkt::message::Message for ClassifyTextRequest {
1655    fn typename() -> &'static str {
1656        "type.googleapis.com/google.cloud.language.v2.ClassifyTextRequest"
1657    }
1658}
1659
1660/// The document classification response message.
1661#[derive(Clone, Default, PartialEq)]
1662#[non_exhaustive]
1663pub struct ClassifyTextResponse {
1664    /// Categories representing the input document.
1665    pub categories: std::vec::Vec<crate::model::ClassificationCategory>,
1666
1667    /// The language of the text, which will be the same as the language specified
1668    /// in the request or, if not specified, the automatically-detected language.
1669    /// See [Document.language][] field for more details.
1670    pub language_code: std::string::String,
1671
1672    /// Whether the language is officially supported. The API may still return a
1673    /// response when the language is not supported, but it is on a best effort
1674    /// basis.
1675    pub language_supported: bool,
1676
1677    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1678}
1679
1680impl ClassifyTextResponse {
1681    pub fn new() -> Self {
1682        std::default::Default::default()
1683    }
1684
1685    /// Sets the value of [categories][crate::model::ClassifyTextResponse::categories].
1686    ///
1687    /// # Example
1688    /// ```ignore,no_run
1689    /// # use google_cloud_language_v2::model::ClassifyTextResponse;
1690    /// use google_cloud_language_v2::model::ClassificationCategory;
1691    /// let x = ClassifyTextResponse::new()
1692    ///     .set_categories([
1693    ///         ClassificationCategory::default()/* use setters */,
1694    ///         ClassificationCategory::default()/* use (different) setters */,
1695    ///     ]);
1696    /// ```
1697    pub fn set_categories<T, V>(mut self, v: T) -> Self
1698    where
1699        T: std::iter::IntoIterator<Item = V>,
1700        V: std::convert::Into<crate::model::ClassificationCategory>,
1701    {
1702        use std::iter::Iterator;
1703        self.categories = v.into_iter().map(|i| i.into()).collect();
1704        self
1705    }
1706
1707    /// Sets the value of [language_code][crate::model::ClassifyTextResponse::language_code].
1708    ///
1709    /// # Example
1710    /// ```ignore,no_run
1711    /// # use google_cloud_language_v2::model::ClassifyTextResponse;
1712    /// let x = ClassifyTextResponse::new().set_language_code("example");
1713    /// ```
1714    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1715        self.language_code = v.into();
1716        self
1717    }
1718
1719    /// Sets the value of [language_supported][crate::model::ClassifyTextResponse::language_supported].
1720    ///
1721    /// # Example
1722    /// ```ignore,no_run
1723    /// # use google_cloud_language_v2::model::ClassifyTextResponse;
1724    /// let x = ClassifyTextResponse::new().set_language_supported(true);
1725    /// ```
1726    pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1727        self.language_supported = v.into();
1728        self
1729    }
1730}
1731
1732impl wkt::message::Message for ClassifyTextResponse {
1733    fn typename() -> &'static str {
1734        "type.googleapis.com/google.cloud.language.v2.ClassifyTextResponse"
1735    }
1736}
1737
1738/// The document moderation request message.
1739#[derive(Clone, Default, PartialEq)]
1740#[non_exhaustive]
1741pub struct ModerateTextRequest {
1742    /// Required. Input document.
1743    pub document: std::option::Option<crate::model::Document>,
1744
1745    /// Optional. The model version to use for ModerateText.
1746    pub model_version: crate::model::moderate_text_request::ModelVersion,
1747
1748    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1749}
1750
1751impl ModerateTextRequest {
1752    pub fn new() -> Self {
1753        std::default::Default::default()
1754    }
1755
1756    /// Sets the value of [document][crate::model::ModerateTextRequest::document].
1757    ///
1758    /// # Example
1759    /// ```ignore,no_run
1760    /// # use google_cloud_language_v2::model::ModerateTextRequest;
1761    /// use google_cloud_language_v2::model::Document;
1762    /// let x = ModerateTextRequest::new().set_document(Document::default()/* use setters */);
1763    /// ```
1764    pub fn set_document<T>(mut self, v: T) -> Self
1765    where
1766        T: std::convert::Into<crate::model::Document>,
1767    {
1768        self.document = std::option::Option::Some(v.into());
1769        self
1770    }
1771
1772    /// Sets or clears the value of [document][crate::model::ModerateTextRequest::document].
1773    ///
1774    /// # Example
1775    /// ```ignore,no_run
1776    /// # use google_cloud_language_v2::model::ModerateTextRequest;
1777    /// use google_cloud_language_v2::model::Document;
1778    /// let x = ModerateTextRequest::new().set_or_clear_document(Some(Document::default()/* use setters */));
1779    /// let x = ModerateTextRequest::new().set_or_clear_document(None::<Document>);
1780    /// ```
1781    pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1782    where
1783        T: std::convert::Into<crate::model::Document>,
1784    {
1785        self.document = v.map(|x| x.into());
1786        self
1787    }
1788
1789    /// Sets the value of [model_version][crate::model::ModerateTextRequest::model_version].
1790    ///
1791    /// # Example
1792    /// ```ignore,no_run
1793    /// # use google_cloud_language_v2::model::ModerateTextRequest;
1794    /// use google_cloud_language_v2::model::moderate_text_request::ModelVersion;
1795    /// let x0 = ModerateTextRequest::new().set_model_version(ModelVersion::ModelVersion1);
1796    /// let x1 = ModerateTextRequest::new().set_model_version(ModelVersion::ModelVersion2);
1797    /// ```
1798    pub fn set_model_version<
1799        T: std::convert::Into<crate::model::moderate_text_request::ModelVersion>,
1800    >(
1801        mut self,
1802        v: T,
1803    ) -> Self {
1804        self.model_version = v.into();
1805        self
1806    }
1807}
1808
1809impl wkt::message::Message for ModerateTextRequest {
1810    fn typename() -> &'static str {
1811        "type.googleapis.com/google.cloud.language.v2.ModerateTextRequest"
1812    }
1813}
1814
1815/// Defines additional types related to [ModerateTextRequest].
1816pub mod moderate_text_request {
1817    #[allow(unused_imports)]
1818    use super::*;
1819
1820    /// The model version to use for ModerateText.
1821    ///
1822    /// # Working with unknown values
1823    ///
1824    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1825    /// additional enum variants at any time. Adding new variants is not considered
1826    /// a breaking change. Applications should write their code in anticipation of:
1827    ///
1828    /// - New values appearing in future releases of the client library, **and**
1829    /// - New values received dynamically, without application changes.
1830    ///
1831    /// Please consult the [Working with enums] section in the user guide for some
1832    /// guidelines.
1833    ///
1834    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1835    #[derive(Clone, Debug, PartialEq)]
1836    #[non_exhaustive]
1837    pub enum ModelVersion {
1838        /// The default model version.
1839        Unspecified,
1840        /// Use the v1 model, this model is used by default when not provided.
1841        /// The v1 model only returns probability (confidence) score for each
1842        /// category.
1843        ModelVersion1,
1844        /// Use the v2 model.
1845        /// The v2 model only returns probability (confidence) score for each
1846        /// category, and returns severity score for a subset of the categories.
1847        ModelVersion2,
1848        /// If set, the enum was initialized with an unknown value.
1849        ///
1850        /// Applications can examine the value using [ModelVersion::value] or
1851        /// [ModelVersion::name].
1852        UnknownValue(model_version::UnknownValue),
1853    }
1854
1855    #[doc(hidden)]
1856    pub mod model_version {
1857        #[allow(unused_imports)]
1858        use super::*;
1859        #[derive(Clone, Debug, PartialEq)]
1860        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1861    }
1862
1863    impl ModelVersion {
1864        /// Gets the enum value.
1865        ///
1866        /// Returns `None` if the enum contains an unknown value deserialized from
1867        /// the string representation of enums.
1868        pub fn value(&self) -> std::option::Option<i32> {
1869            match self {
1870                Self::Unspecified => std::option::Option::Some(0),
1871                Self::ModelVersion1 => std::option::Option::Some(1),
1872                Self::ModelVersion2 => std::option::Option::Some(2),
1873                Self::UnknownValue(u) => u.0.value(),
1874            }
1875        }
1876
1877        /// Gets the enum value as a string.
1878        ///
1879        /// Returns `None` if the enum contains an unknown value deserialized from
1880        /// the integer representation of enums.
1881        pub fn name(&self) -> std::option::Option<&str> {
1882            match self {
1883                Self::Unspecified => std::option::Option::Some("MODEL_VERSION_UNSPECIFIED"),
1884                Self::ModelVersion1 => std::option::Option::Some("MODEL_VERSION_1"),
1885                Self::ModelVersion2 => std::option::Option::Some("MODEL_VERSION_2"),
1886                Self::UnknownValue(u) => u.0.name(),
1887            }
1888        }
1889    }
1890
1891    impl std::default::Default for ModelVersion {
1892        fn default() -> Self {
1893            use std::convert::From;
1894            Self::from(0)
1895        }
1896    }
1897
1898    impl std::fmt::Display for ModelVersion {
1899        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1900            wkt::internal::display_enum(f, self.name(), self.value())
1901        }
1902    }
1903
1904    impl std::convert::From<i32> for ModelVersion {
1905        fn from(value: i32) -> Self {
1906            match value {
1907                0 => Self::Unspecified,
1908                1 => Self::ModelVersion1,
1909                2 => Self::ModelVersion2,
1910                _ => Self::UnknownValue(model_version::UnknownValue(
1911                    wkt::internal::UnknownEnumValue::Integer(value),
1912                )),
1913            }
1914        }
1915    }
1916
1917    impl std::convert::From<&str> for ModelVersion {
1918        fn from(value: &str) -> Self {
1919            use std::string::ToString;
1920            match value {
1921                "MODEL_VERSION_UNSPECIFIED" => Self::Unspecified,
1922                "MODEL_VERSION_1" => Self::ModelVersion1,
1923                "MODEL_VERSION_2" => Self::ModelVersion2,
1924                _ => Self::UnknownValue(model_version::UnknownValue(
1925                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1926                )),
1927            }
1928        }
1929    }
1930
1931    impl serde::ser::Serialize for ModelVersion {
1932        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1933        where
1934            S: serde::Serializer,
1935        {
1936            match self {
1937                Self::Unspecified => serializer.serialize_i32(0),
1938                Self::ModelVersion1 => serializer.serialize_i32(1),
1939                Self::ModelVersion2 => serializer.serialize_i32(2),
1940                Self::UnknownValue(u) => u.0.serialize(serializer),
1941            }
1942        }
1943    }
1944
1945    impl<'de> serde::de::Deserialize<'de> for ModelVersion {
1946        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1947        where
1948            D: serde::Deserializer<'de>,
1949        {
1950            deserializer.deserialize_any(wkt::internal::EnumVisitor::<ModelVersion>::new(
1951                ".google.cloud.language.v2.ModerateTextRequest.ModelVersion",
1952            ))
1953        }
1954    }
1955}
1956
1957/// The document moderation response message.
1958#[derive(Clone, Default, PartialEq)]
1959#[non_exhaustive]
1960pub struct ModerateTextResponse {
1961    /// Harmful and sensitive categories representing the input document.
1962    pub moderation_categories: std::vec::Vec<crate::model::ClassificationCategory>,
1963
1964    /// The language of the text, which will be the same as the language specified
1965    /// in the request or, if not specified, the automatically-detected language.
1966    /// See [Document.language][] field for more details.
1967    pub language_code: std::string::String,
1968
1969    /// Whether the language is officially supported. The API may still return a
1970    /// response when the language is not supported, but it is on a best effort
1971    /// basis.
1972    pub language_supported: bool,
1973
1974    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1975}
1976
1977impl ModerateTextResponse {
1978    pub fn new() -> Self {
1979        std::default::Default::default()
1980    }
1981
1982    /// Sets the value of [moderation_categories][crate::model::ModerateTextResponse::moderation_categories].
1983    ///
1984    /// # Example
1985    /// ```ignore,no_run
1986    /// # use google_cloud_language_v2::model::ModerateTextResponse;
1987    /// use google_cloud_language_v2::model::ClassificationCategory;
1988    /// let x = ModerateTextResponse::new()
1989    ///     .set_moderation_categories([
1990    ///         ClassificationCategory::default()/* use setters */,
1991    ///         ClassificationCategory::default()/* use (different) setters */,
1992    ///     ]);
1993    /// ```
1994    pub fn set_moderation_categories<T, V>(mut self, v: T) -> Self
1995    where
1996        T: std::iter::IntoIterator<Item = V>,
1997        V: std::convert::Into<crate::model::ClassificationCategory>,
1998    {
1999        use std::iter::Iterator;
2000        self.moderation_categories = v.into_iter().map(|i| i.into()).collect();
2001        self
2002    }
2003
2004    /// Sets the value of [language_code][crate::model::ModerateTextResponse::language_code].
2005    ///
2006    /// # Example
2007    /// ```ignore,no_run
2008    /// # use google_cloud_language_v2::model::ModerateTextResponse;
2009    /// let x = ModerateTextResponse::new().set_language_code("example");
2010    /// ```
2011    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2012        self.language_code = v.into();
2013        self
2014    }
2015
2016    /// Sets the value of [language_supported][crate::model::ModerateTextResponse::language_supported].
2017    ///
2018    /// # Example
2019    /// ```ignore,no_run
2020    /// # use google_cloud_language_v2::model::ModerateTextResponse;
2021    /// let x = ModerateTextResponse::new().set_language_supported(true);
2022    /// ```
2023    pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2024        self.language_supported = v.into();
2025        self
2026    }
2027}
2028
2029impl wkt::message::Message for ModerateTextResponse {
2030    fn typename() -> &'static str {
2031        "type.googleapis.com/google.cloud.language.v2.ModerateTextResponse"
2032    }
2033}
2034
2035/// The request message for the text annotation API, which can perform multiple
2036/// analysis types in one call.
2037#[derive(Clone, Default, PartialEq)]
2038#[non_exhaustive]
2039pub struct AnnotateTextRequest {
2040    /// Required. Input document.
2041    pub document: std::option::Option<crate::model::Document>,
2042
2043    /// Required. The enabled features.
2044    pub features: std::option::Option<crate::model::annotate_text_request::Features>,
2045
2046    /// The encoding type used by the API to calculate offsets.
2047    pub encoding_type: crate::model::EncodingType,
2048
2049    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2050}
2051
2052impl AnnotateTextRequest {
2053    pub fn new() -> Self {
2054        std::default::Default::default()
2055    }
2056
2057    /// Sets the value of [document][crate::model::AnnotateTextRequest::document].
2058    ///
2059    /// # Example
2060    /// ```ignore,no_run
2061    /// # use google_cloud_language_v2::model::AnnotateTextRequest;
2062    /// use google_cloud_language_v2::model::Document;
2063    /// let x = AnnotateTextRequest::new().set_document(Document::default()/* use setters */);
2064    /// ```
2065    pub fn set_document<T>(mut self, v: T) -> Self
2066    where
2067        T: std::convert::Into<crate::model::Document>,
2068    {
2069        self.document = std::option::Option::Some(v.into());
2070        self
2071    }
2072
2073    /// Sets or clears the value of [document][crate::model::AnnotateTextRequest::document].
2074    ///
2075    /// # Example
2076    /// ```ignore,no_run
2077    /// # use google_cloud_language_v2::model::AnnotateTextRequest;
2078    /// use google_cloud_language_v2::model::Document;
2079    /// let x = AnnotateTextRequest::new().set_or_clear_document(Some(Document::default()/* use setters */));
2080    /// let x = AnnotateTextRequest::new().set_or_clear_document(None::<Document>);
2081    /// ```
2082    pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
2083    where
2084        T: std::convert::Into<crate::model::Document>,
2085    {
2086        self.document = v.map(|x| x.into());
2087        self
2088    }
2089
2090    /// Sets the value of [features][crate::model::AnnotateTextRequest::features].
2091    ///
2092    /// # Example
2093    /// ```ignore,no_run
2094    /// # use google_cloud_language_v2::model::AnnotateTextRequest;
2095    /// use google_cloud_language_v2::model::annotate_text_request::Features;
2096    /// let x = AnnotateTextRequest::new().set_features(Features::default()/* use setters */);
2097    /// ```
2098    pub fn set_features<T>(mut self, v: T) -> Self
2099    where
2100        T: std::convert::Into<crate::model::annotate_text_request::Features>,
2101    {
2102        self.features = std::option::Option::Some(v.into());
2103        self
2104    }
2105
2106    /// Sets or clears the value of [features][crate::model::AnnotateTextRequest::features].
2107    ///
2108    /// # Example
2109    /// ```ignore,no_run
2110    /// # use google_cloud_language_v2::model::AnnotateTextRequest;
2111    /// use google_cloud_language_v2::model::annotate_text_request::Features;
2112    /// let x = AnnotateTextRequest::new().set_or_clear_features(Some(Features::default()/* use setters */));
2113    /// let x = AnnotateTextRequest::new().set_or_clear_features(None::<Features>);
2114    /// ```
2115    pub fn set_or_clear_features<T>(mut self, v: std::option::Option<T>) -> Self
2116    where
2117        T: std::convert::Into<crate::model::annotate_text_request::Features>,
2118    {
2119        self.features = v.map(|x| x.into());
2120        self
2121    }
2122
2123    /// Sets the value of [encoding_type][crate::model::AnnotateTextRequest::encoding_type].
2124    ///
2125    /// # Example
2126    /// ```ignore,no_run
2127    /// # use google_cloud_language_v2::model::AnnotateTextRequest;
2128    /// use google_cloud_language_v2::model::EncodingType;
2129    /// let x0 = AnnotateTextRequest::new().set_encoding_type(EncodingType::Utf8);
2130    /// let x1 = AnnotateTextRequest::new().set_encoding_type(EncodingType::Utf16);
2131    /// let x2 = AnnotateTextRequest::new().set_encoding_type(EncodingType::Utf32);
2132    /// ```
2133    pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
2134        mut self,
2135        v: T,
2136    ) -> Self {
2137        self.encoding_type = v.into();
2138        self
2139    }
2140}
2141
2142impl wkt::message::Message for AnnotateTextRequest {
2143    fn typename() -> &'static str {
2144        "type.googleapis.com/google.cloud.language.v2.AnnotateTextRequest"
2145    }
2146}
2147
2148/// Defines additional types related to [AnnotateTextRequest].
2149pub mod annotate_text_request {
2150    #[allow(unused_imports)]
2151    use super::*;
2152
2153    /// All available features.
2154    /// Setting each one to true will enable that specific analysis for the input.
2155    #[derive(Clone, Default, PartialEq)]
2156    #[non_exhaustive]
2157    pub struct Features {
2158        /// Optional. Extract entities.
2159        pub extract_entities: bool,
2160
2161        /// Optional. Extract document-level sentiment.
2162        pub extract_document_sentiment: bool,
2163
2164        /// Optional. Classify the full document into categories.
2165        pub classify_text: bool,
2166
2167        /// Optional. Moderate the document for harmful and sensitive categories.
2168        pub moderate_text: bool,
2169
2170        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2171    }
2172
2173    impl Features {
2174        pub fn new() -> Self {
2175            std::default::Default::default()
2176        }
2177
2178        /// Sets the value of [extract_entities][crate::model::annotate_text_request::Features::extract_entities].
2179        ///
2180        /// # Example
2181        /// ```ignore,no_run
2182        /// # use google_cloud_language_v2::model::annotate_text_request::Features;
2183        /// let x = Features::new().set_extract_entities(true);
2184        /// ```
2185        pub fn set_extract_entities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2186            self.extract_entities = v.into();
2187            self
2188        }
2189
2190        /// Sets the value of [extract_document_sentiment][crate::model::annotate_text_request::Features::extract_document_sentiment].
2191        ///
2192        /// # Example
2193        /// ```ignore,no_run
2194        /// # use google_cloud_language_v2::model::annotate_text_request::Features;
2195        /// let x = Features::new().set_extract_document_sentiment(true);
2196        /// ```
2197        pub fn set_extract_document_sentiment<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2198            self.extract_document_sentiment = v.into();
2199            self
2200        }
2201
2202        /// Sets the value of [classify_text][crate::model::annotate_text_request::Features::classify_text].
2203        ///
2204        /// # Example
2205        /// ```ignore,no_run
2206        /// # use google_cloud_language_v2::model::annotate_text_request::Features;
2207        /// let x = Features::new().set_classify_text(true);
2208        /// ```
2209        pub fn set_classify_text<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2210            self.classify_text = v.into();
2211            self
2212        }
2213
2214        /// Sets the value of [moderate_text][crate::model::annotate_text_request::Features::moderate_text].
2215        ///
2216        /// # Example
2217        /// ```ignore,no_run
2218        /// # use google_cloud_language_v2::model::annotate_text_request::Features;
2219        /// let x = Features::new().set_moderate_text(true);
2220        /// ```
2221        pub fn set_moderate_text<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2222            self.moderate_text = v.into();
2223            self
2224        }
2225    }
2226
2227    impl wkt::message::Message for Features {
2228        fn typename() -> &'static str {
2229            "type.googleapis.com/google.cloud.language.v2.AnnotateTextRequest.Features"
2230        }
2231    }
2232}
2233
2234/// The text annotations response message.
2235#[derive(Clone, Default, PartialEq)]
2236#[non_exhaustive]
2237pub struct AnnotateTextResponse {
2238    /// Sentences in the input document. Populated if the user enables
2239    /// [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment].
2240    ///
2241    /// [google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment]: crate::model::annotate_text_request::Features::extract_document_sentiment
2242    pub sentences: std::vec::Vec<crate::model::Sentence>,
2243
2244    /// Entities, along with their semantic information, in the input document.
2245    /// Populated if the user enables
2246    /// [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entities]
2247    /// or
2248    /// [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entity_sentiment].
2249    ///
2250    /// [google.cloud.language.v2.AnnotateTextRequest.Features.extract_entities]: crate::model::annotate_text_request::Features::extract_entities
2251    pub entities: std::vec::Vec<crate::model::Entity>,
2252
2253    /// The overall sentiment for the document. Populated if the user enables
2254    /// [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment].
2255    ///
2256    /// [google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment]: crate::model::annotate_text_request::Features::extract_document_sentiment
2257    pub document_sentiment: std::option::Option<crate::model::Sentiment>,
2258
2259    /// The language of the text, which will be the same as the language specified
2260    /// in the request or, if not specified, the automatically-detected language.
2261    /// See [Document.language][] field for more details.
2262    pub language_code: std::string::String,
2263
2264    /// Categories identified in the input document.
2265    pub categories: std::vec::Vec<crate::model::ClassificationCategory>,
2266
2267    /// Harmful and sensitive categories identified in the input document.
2268    pub moderation_categories: std::vec::Vec<crate::model::ClassificationCategory>,
2269
2270    /// Whether the language is officially supported by all requested features.
2271    /// The API may still return a response when the language is not supported, but
2272    /// it is on a best effort basis.
2273    pub language_supported: bool,
2274
2275    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2276}
2277
2278impl AnnotateTextResponse {
2279    pub fn new() -> Self {
2280        std::default::Default::default()
2281    }
2282
2283    /// Sets the value of [sentences][crate::model::AnnotateTextResponse::sentences].
2284    ///
2285    /// # Example
2286    /// ```ignore,no_run
2287    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2288    /// use google_cloud_language_v2::model::Sentence;
2289    /// let x = AnnotateTextResponse::new()
2290    ///     .set_sentences([
2291    ///         Sentence::default()/* use setters */,
2292    ///         Sentence::default()/* use (different) setters */,
2293    ///     ]);
2294    /// ```
2295    pub fn set_sentences<T, V>(mut self, v: T) -> Self
2296    where
2297        T: std::iter::IntoIterator<Item = V>,
2298        V: std::convert::Into<crate::model::Sentence>,
2299    {
2300        use std::iter::Iterator;
2301        self.sentences = v.into_iter().map(|i| i.into()).collect();
2302        self
2303    }
2304
2305    /// Sets the value of [entities][crate::model::AnnotateTextResponse::entities].
2306    ///
2307    /// # Example
2308    /// ```ignore,no_run
2309    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2310    /// use google_cloud_language_v2::model::Entity;
2311    /// let x = AnnotateTextResponse::new()
2312    ///     .set_entities([
2313    ///         Entity::default()/* use setters */,
2314    ///         Entity::default()/* use (different) setters */,
2315    ///     ]);
2316    /// ```
2317    pub fn set_entities<T, V>(mut self, v: T) -> Self
2318    where
2319        T: std::iter::IntoIterator<Item = V>,
2320        V: std::convert::Into<crate::model::Entity>,
2321    {
2322        use std::iter::Iterator;
2323        self.entities = v.into_iter().map(|i| i.into()).collect();
2324        self
2325    }
2326
2327    /// Sets the value of [document_sentiment][crate::model::AnnotateTextResponse::document_sentiment].
2328    ///
2329    /// # Example
2330    /// ```ignore,no_run
2331    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2332    /// use google_cloud_language_v2::model::Sentiment;
2333    /// let x = AnnotateTextResponse::new().set_document_sentiment(Sentiment::default()/* use setters */);
2334    /// ```
2335    pub fn set_document_sentiment<T>(mut self, v: T) -> Self
2336    where
2337        T: std::convert::Into<crate::model::Sentiment>,
2338    {
2339        self.document_sentiment = std::option::Option::Some(v.into());
2340        self
2341    }
2342
2343    /// Sets or clears the value of [document_sentiment][crate::model::AnnotateTextResponse::document_sentiment].
2344    ///
2345    /// # Example
2346    /// ```ignore,no_run
2347    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2348    /// use google_cloud_language_v2::model::Sentiment;
2349    /// let x = AnnotateTextResponse::new().set_or_clear_document_sentiment(Some(Sentiment::default()/* use setters */));
2350    /// let x = AnnotateTextResponse::new().set_or_clear_document_sentiment(None::<Sentiment>);
2351    /// ```
2352    pub fn set_or_clear_document_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
2353    where
2354        T: std::convert::Into<crate::model::Sentiment>,
2355    {
2356        self.document_sentiment = v.map(|x| x.into());
2357        self
2358    }
2359
2360    /// Sets the value of [language_code][crate::model::AnnotateTextResponse::language_code].
2361    ///
2362    /// # Example
2363    /// ```ignore,no_run
2364    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2365    /// let x = AnnotateTextResponse::new().set_language_code("example");
2366    /// ```
2367    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2368        self.language_code = v.into();
2369        self
2370    }
2371
2372    /// Sets the value of [categories][crate::model::AnnotateTextResponse::categories].
2373    ///
2374    /// # Example
2375    /// ```ignore,no_run
2376    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2377    /// use google_cloud_language_v2::model::ClassificationCategory;
2378    /// let x = AnnotateTextResponse::new()
2379    ///     .set_categories([
2380    ///         ClassificationCategory::default()/* use setters */,
2381    ///         ClassificationCategory::default()/* use (different) setters */,
2382    ///     ]);
2383    /// ```
2384    pub fn set_categories<T, V>(mut self, v: T) -> Self
2385    where
2386        T: std::iter::IntoIterator<Item = V>,
2387        V: std::convert::Into<crate::model::ClassificationCategory>,
2388    {
2389        use std::iter::Iterator;
2390        self.categories = v.into_iter().map(|i| i.into()).collect();
2391        self
2392    }
2393
2394    /// Sets the value of [moderation_categories][crate::model::AnnotateTextResponse::moderation_categories].
2395    ///
2396    /// # Example
2397    /// ```ignore,no_run
2398    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2399    /// use google_cloud_language_v2::model::ClassificationCategory;
2400    /// let x = AnnotateTextResponse::new()
2401    ///     .set_moderation_categories([
2402    ///         ClassificationCategory::default()/* use setters */,
2403    ///         ClassificationCategory::default()/* use (different) setters */,
2404    ///     ]);
2405    /// ```
2406    pub fn set_moderation_categories<T, V>(mut self, v: T) -> Self
2407    where
2408        T: std::iter::IntoIterator<Item = V>,
2409        V: std::convert::Into<crate::model::ClassificationCategory>,
2410    {
2411        use std::iter::Iterator;
2412        self.moderation_categories = v.into_iter().map(|i| i.into()).collect();
2413        self
2414    }
2415
2416    /// Sets the value of [language_supported][crate::model::AnnotateTextResponse::language_supported].
2417    ///
2418    /// # Example
2419    /// ```ignore,no_run
2420    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2421    /// let x = AnnotateTextResponse::new().set_language_supported(true);
2422    /// ```
2423    pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2424        self.language_supported = v.into();
2425        self
2426    }
2427}
2428
2429impl wkt::message::Message for AnnotateTextResponse {
2430    fn typename() -> &'static str {
2431        "type.googleapis.com/google.cloud.language.v2.AnnotateTextResponse"
2432    }
2433}
2434
2435/// Represents the text encoding that the caller uses to process the output.
2436/// Providing an `EncodingType` is recommended because the API provides the
2437/// beginning offsets for various outputs, such as tokens and mentions, and
2438/// languages that natively use different text encodings may access offsets
2439/// differently.
2440///
2441/// # Working with unknown values
2442///
2443/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2444/// additional enum variants at any time. Adding new variants is not considered
2445/// a breaking change. Applications should write their code in anticipation of:
2446///
2447/// - New values appearing in future releases of the client library, **and**
2448/// - New values received dynamically, without application changes.
2449///
2450/// Please consult the [Working with enums] section in the user guide for some
2451/// guidelines.
2452///
2453/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
2454#[derive(Clone, Debug, PartialEq)]
2455#[non_exhaustive]
2456pub enum EncodingType {
2457    /// If `EncodingType` is not specified, encoding-dependent information (such as
2458    /// `begin_offset`) will be set at `-1`.
2459    None,
2460    /// Encoding-dependent information (such as `begin_offset`) is calculated based
2461    /// on the UTF-8 encoding of the input. C++ and Go are examples of languages
2462    /// that use this encoding natively.
2463    Utf8,
2464    /// Encoding-dependent information (such as `begin_offset`) is calculated based
2465    /// on the UTF-16 encoding of the input. Java and JavaScript are examples of
2466    /// languages that use this encoding natively.
2467    Utf16,
2468    /// Encoding-dependent information (such as `begin_offset`) is calculated based
2469    /// on the UTF-32 encoding of the input. Python is an example of a language
2470    /// that uses this encoding natively.
2471    Utf32,
2472    /// If set, the enum was initialized with an unknown value.
2473    ///
2474    /// Applications can examine the value using [EncodingType::value] or
2475    /// [EncodingType::name].
2476    UnknownValue(encoding_type::UnknownValue),
2477}
2478
2479#[doc(hidden)]
2480pub mod encoding_type {
2481    #[allow(unused_imports)]
2482    use super::*;
2483    #[derive(Clone, Debug, PartialEq)]
2484    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2485}
2486
2487impl EncodingType {
2488    /// Gets the enum value.
2489    ///
2490    /// Returns `None` if the enum contains an unknown value deserialized from
2491    /// the string representation of enums.
2492    pub fn value(&self) -> std::option::Option<i32> {
2493        match self {
2494            Self::None => std::option::Option::Some(0),
2495            Self::Utf8 => std::option::Option::Some(1),
2496            Self::Utf16 => std::option::Option::Some(2),
2497            Self::Utf32 => std::option::Option::Some(3),
2498            Self::UnknownValue(u) => u.0.value(),
2499        }
2500    }
2501
2502    /// Gets the enum value as a string.
2503    ///
2504    /// Returns `None` if the enum contains an unknown value deserialized from
2505    /// the integer representation of enums.
2506    pub fn name(&self) -> std::option::Option<&str> {
2507        match self {
2508            Self::None => std::option::Option::Some("NONE"),
2509            Self::Utf8 => std::option::Option::Some("UTF8"),
2510            Self::Utf16 => std::option::Option::Some("UTF16"),
2511            Self::Utf32 => std::option::Option::Some("UTF32"),
2512            Self::UnknownValue(u) => u.0.name(),
2513        }
2514    }
2515}
2516
2517impl std::default::Default for EncodingType {
2518    fn default() -> Self {
2519        use std::convert::From;
2520        Self::from(0)
2521    }
2522}
2523
2524impl std::fmt::Display for EncodingType {
2525    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2526        wkt::internal::display_enum(f, self.name(), self.value())
2527    }
2528}
2529
2530impl std::convert::From<i32> for EncodingType {
2531    fn from(value: i32) -> Self {
2532        match value {
2533            0 => Self::None,
2534            1 => Self::Utf8,
2535            2 => Self::Utf16,
2536            3 => Self::Utf32,
2537            _ => Self::UnknownValue(encoding_type::UnknownValue(
2538                wkt::internal::UnknownEnumValue::Integer(value),
2539            )),
2540        }
2541    }
2542}
2543
2544impl std::convert::From<&str> for EncodingType {
2545    fn from(value: &str) -> Self {
2546        use std::string::ToString;
2547        match value {
2548            "NONE" => Self::None,
2549            "UTF8" => Self::Utf8,
2550            "UTF16" => Self::Utf16,
2551            "UTF32" => Self::Utf32,
2552            _ => Self::UnknownValue(encoding_type::UnknownValue(
2553                wkt::internal::UnknownEnumValue::String(value.to_string()),
2554            )),
2555        }
2556    }
2557}
2558
2559impl serde::ser::Serialize for EncodingType {
2560    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2561    where
2562        S: serde::Serializer,
2563    {
2564        match self {
2565            Self::None => serializer.serialize_i32(0),
2566            Self::Utf8 => serializer.serialize_i32(1),
2567            Self::Utf16 => serializer.serialize_i32(2),
2568            Self::Utf32 => serializer.serialize_i32(3),
2569            Self::UnknownValue(u) => u.0.serialize(serializer),
2570        }
2571    }
2572}
2573
2574impl<'de> serde::de::Deserialize<'de> for EncodingType {
2575    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2576    where
2577        D: serde::Deserializer<'de>,
2578    {
2579        deserializer.deserialize_any(wkt::internal::EnumVisitor::<EncodingType>::new(
2580            ".google.cloud.language.v2.EncodingType",
2581        ))
2582    }
2583}