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