Skip to main content

google_cloud_language_v2/
model.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gaxi;
23extern crate google_cloud_gax;
24extern crate serde;
25extern crate serde_json;
26extern crate serde_with;
27extern crate std;
28extern crate tracing;
29extern crate wkt;
30
31mod debug;
32mod deserialize;
33mod serialize;
34
35/// Represents the input to API methods.
36#[derive(Clone, Default, PartialEq)]
37#[non_exhaustive]
38pub struct Document {
39    /// Required. If the type is not set or is `TYPE_UNSPECIFIED`,
40    /// returns an `INVALID_ARGUMENT` error.
41    pub r#type: crate::model::document::Type,
42
43    /// Optional. The language of the document (if not specified, the language is
44    /// automatically detected). Both ISO and BCP-47 language codes are
45    /// accepted.\<br\>
46    /// [Language
47    /// Support](https://cloud.google.com/natural-language/docs/languages) lists
48    /// currently supported languages for each API method. If the language (either
49    /// specified by the caller or automatically detected) is not supported by the
50    /// called API method, an `INVALID_ARGUMENT` error is returned.
51    pub language_code: std::string::String,
52
53    /// The source of the document: a string containing the content or a
54    /// Google Cloud Storage URI.
55    pub source: std::option::Option<crate::model::document::Source>,
56
57    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
58}
59
60impl Document {
61    /// Creates a new default instance.
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://googleapis.github.io/google-cloud-rust/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    pub sentiment: std::option::Option<crate::model::Sentiment>,
343
344    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
345}
346
347impl Sentence {
348    /// Creates a new default instance.
349    pub fn new() -> Self {
350        std::default::Default::default()
351    }
352
353    /// Sets the value of [text][crate::model::Sentence::text].
354    ///
355    /// # Example
356    /// ```ignore,no_run
357    /// # use google_cloud_language_v2::model::Sentence;
358    /// use google_cloud_language_v2::model::TextSpan;
359    /// let x = Sentence::new().set_text(TextSpan::default()/* use setters */);
360    /// ```
361    pub fn set_text<T>(mut self, v: T) -> Self
362    where
363        T: std::convert::Into<crate::model::TextSpan>,
364    {
365        self.text = std::option::Option::Some(v.into());
366        self
367    }
368
369    /// Sets or clears the value of [text][crate::model::Sentence::text].
370    ///
371    /// # Example
372    /// ```ignore,no_run
373    /// # use google_cloud_language_v2::model::Sentence;
374    /// use google_cloud_language_v2::model::TextSpan;
375    /// let x = Sentence::new().set_or_clear_text(Some(TextSpan::default()/* use setters */));
376    /// let x = Sentence::new().set_or_clear_text(None::<TextSpan>);
377    /// ```
378    pub fn set_or_clear_text<T>(mut self, v: std::option::Option<T>) -> Self
379    where
380        T: std::convert::Into<crate::model::TextSpan>,
381    {
382        self.text = v.map(|x| x.into());
383        self
384    }
385
386    /// Sets the value of [sentiment][crate::model::Sentence::sentiment].
387    ///
388    /// # Example
389    /// ```ignore,no_run
390    /// # use google_cloud_language_v2::model::Sentence;
391    /// use google_cloud_language_v2::model::Sentiment;
392    /// let x = Sentence::new().set_sentiment(Sentiment::default()/* use setters */);
393    /// ```
394    pub fn set_sentiment<T>(mut self, v: T) -> Self
395    where
396        T: std::convert::Into<crate::model::Sentiment>,
397    {
398        self.sentiment = std::option::Option::Some(v.into());
399        self
400    }
401
402    /// Sets or clears the value of [sentiment][crate::model::Sentence::sentiment].
403    ///
404    /// # Example
405    /// ```ignore,no_run
406    /// # use google_cloud_language_v2::model::Sentence;
407    /// use google_cloud_language_v2::model::Sentiment;
408    /// let x = Sentence::new().set_or_clear_sentiment(Some(Sentiment::default()/* use setters */));
409    /// let x = Sentence::new().set_or_clear_sentiment(None::<Sentiment>);
410    /// ```
411    pub fn set_or_clear_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
412    where
413        T: std::convert::Into<crate::model::Sentiment>,
414    {
415        self.sentiment = v.map(|x| x.into());
416        self
417    }
418}
419
420impl wkt::message::Message for Sentence {
421    fn typename() -> &'static str {
422        "type.googleapis.com/google.cloud.language.v2.Sentence"
423    }
424}
425
426/// Represents a phrase in the text that is a known entity, such as
427/// a person, an organization, or location. The API associates information, such
428/// as probability and mentions, with entities.
429#[derive(Clone, Default, PartialEq)]
430#[non_exhaustive]
431pub struct Entity {
432    /// The representative name for the entity.
433    pub name: std::string::String,
434
435    /// The entity type.
436    pub r#type: crate::model::entity::Type,
437
438    /// Metadata associated with the entity.
439    ///
440    /// For the metadata
441    /// associated with other entity types, see the Type table below.
442    pub metadata: std::collections::HashMap<std::string::String, std::string::String>,
443
444    /// The mentions of this entity in the input document. The API currently
445    /// supports proper noun mentions.
446    pub mentions: std::vec::Vec<crate::model::EntityMention>,
447
448    /// For calls to [AnalyzeEntitySentiment][] or if
449    /// [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entity_sentiment]
450    /// is set to true, this field will contain the aggregate sentiment expressed
451    /// for this entity in the provided document.
452    pub sentiment: std::option::Option<crate::model::Sentiment>,
453
454    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
455}
456
457impl Entity {
458    /// Creates a new default instance.
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://googleapis.github.io/google-cloud-rust/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    /// Creates a new default instance.
836    pub fn new() -> Self {
837        std::default::Default::default()
838    }
839
840    /// Sets the value of [magnitude][crate::model::Sentiment::magnitude].
841    ///
842    /// # Example
843    /// ```ignore,no_run
844    /// # use google_cloud_language_v2::model::Sentiment;
845    /// let x = Sentiment::new().set_magnitude(42.0);
846    /// ```
847    pub fn set_magnitude<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
848        self.magnitude = v.into();
849        self
850    }
851
852    /// Sets the value of [score][crate::model::Sentiment::score].
853    ///
854    /// # Example
855    /// ```ignore,no_run
856    /// # use google_cloud_language_v2::model::Sentiment;
857    /// let x = Sentiment::new().set_score(42.0);
858    /// ```
859    pub fn set_score<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
860        self.score = v.into();
861        self
862    }
863}
864
865impl wkt::message::Message for Sentiment {
866    fn typename() -> &'static str {
867        "type.googleapis.com/google.cloud.language.v2.Sentiment"
868    }
869}
870
871/// Represents a mention for an entity in the text. Currently, proper noun
872/// mentions are supported.
873#[derive(Clone, Default, PartialEq)]
874#[non_exhaustive]
875pub struct EntityMention {
876    /// The mention text.
877    pub text: std::option::Option<crate::model::TextSpan>,
878
879    /// The type of the entity mention.
880    pub r#type: crate::model::entity_mention::Type,
881
882    /// For calls to [AnalyzeEntitySentiment][] or if
883    /// [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entity_sentiment]
884    /// is set to true, this field will contain the sentiment expressed for this
885    /// mention of the entity in the provided document.
886    pub sentiment: std::option::Option<crate::model::Sentiment>,
887
888    /// Probability score associated with the entity.
889    ///
890    /// The score shows the probability of the entity mention being the entity
891    /// type. The score is in (0, 1] range.
892    pub probability: f32,
893
894    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
895}
896
897impl EntityMention {
898    /// Creates a new default instance.
899    pub fn new() -> Self {
900        std::default::Default::default()
901    }
902
903    /// Sets the value of [text][crate::model::EntityMention::text].
904    ///
905    /// # Example
906    /// ```ignore,no_run
907    /// # use google_cloud_language_v2::model::EntityMention;
908    /// use google_cloud_language_v2::model::TextSpan;
909    /// let x = EntityMention::new().set_text(TextSpan::default()/* use setters */);
910    /// ```
911    pub fn set_text<T>(mut self, v: T) -> Self
912    where
913        T: std::convert::Into<crate::model::TextSpan>,
914    {
915        self.text = std::option::Option::Some(v.into());
916        self
917    }
918
919    /// Sets or clears the value of [text][crate::model::EntityMention::text].
920    ///
921    /// # Example
922    /// ```ignore,no_run
923    /// # use google_cloud_language_v2::model::EntityMention;
924    /// use google_cloud_language_v2::model::TextSpan;
925    /// let x = EntityMention::new().set_or_clear_text(Some(TextSpan::default()/* use setters */));
926    /// let x = EntityMention::new().set_or_clear_text(None::<TextSpan>);
927    /// ```
928    pub fn set_or_clear_text<T>(mut self, v: std::option::Option<T>) -> Self
929    where
930        T: std::convert::Into<crate::model::TextSpan>,
931    {
932        self.text = v.map(|x| x.into());
933        self
934    }
935
936    /// Sets the value of [r#type][crate::model::EntityMention::type].
937    ///
938    /// # Example
939    /// ```ignore,no_run
940    /// # use google_cloud_language_v2::model::EntityMention;
941    /// use google_cloud_language_v2::model::entity_mention::Type;
942    /// let x0 = EntityMention::new().set_type(Type::Proper);
943    /// let x1 = EntityMention::new().set_type(Type::Common);
944    /// ```
945    pub fn set_type<T: std::convert::Into<crate::model::entity_mention::Type>>(
946        mut self,
947        v: T,
948    ) -> Self {
949        self.r#type = v.into();
950        self
951    }
952
953    /// Sets the value of [sentiment][crate::model::EntityMention::sentiment].
954    ///
955    /// # Example
956    /// ```ignore,no_run
957    /// # use google_cloud_language_v2::model::EntityMention;
958    /// use google_cloud_language_v2::model::Sentiment;
959    /// let x = EntityMention::new().set_sentiment(Sentiment::default()/* use setters */);
960    /// ```
961    pub fn set_sentiment<T>(mut self, v: T) -> Self
962    where
963        T: std::convert::Into<crate::model::Sentiment>,
964    {
965        self.sentiment = std::option::Option::Some(v.into());
966        self
967    }
968
969    /// Sets or clears the value of [sentiment][crate::model::EntityMention::sentiment].
970    ///
971    /// # Example
972    /// ```ignore,no_run
973    /// # use google_cloud_language_v2::model::EntityMention;
974    /// use google_cloud_language_v2::model::Sentiment;
975    /// let x = EntityMention::new().set_or_clear_sentiment(Some(Sentiment::default()/* use setters */));
976    /// let x = EntityMention::new().set_or_clear_sentiment(None::<Sentiment>);
977    /// ```
978    pub fn set_or_clear_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
979    where
980        T: std::convert::Into<crate::model::Sentiment>,
981    {
982        self.sentiment = v.map(|x| x.into());
983        self
984    }
985
986    /// Sets the value of [probability][crate::model::EntityMention::probability].
987    ///
988    /// # Example
989    /// ```ignore,no_run
990    /// # use google_cloud_language_v2::model::EntityMention;
991    /// let x = EntityMention::new().set_probability(42.0);
992    /// ```
993    pub fn set_probability<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
994        self.probability = v.into();
995        self
996    }
997}
998
999impl wkt::message::Message for EntityMention {
1000    fn typename() -> &'static str {
1001        "type.googleapis.com/google.cloud.language.v2.EntityMention"
1002    }
1003}
1004
1005/// Defines additional types related to [EntityMention].
1006pub mod entity_mention {
1007    #[allow(unused_imports)]
1008    use super::*;
1009
1010    /// The supported types of mentions.
1011    ///
1012    /// # Working with unknown values
1013    ///
1014    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1015    /// additional enum variants at any time. Adding new variants is not considered
1016    /// a breaking change. Applications should write their code in anticipation of:
1017    ///
1018    /// - New values appearing in future releases of the client library, **and**
1019    /// - New values received dynamically, without application changes.
1020    ///
1021    /// Please consult the [Working with enums] section in the user guide for some
1022    /// guidelines.
1023    ///
1024    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1025    #[derive(Clone, Debug, PartialEq)]
1026    #[non_exhaustive]
1027    pub enum Type {
1028        /// Unknown
1029        Unknown,
1030        /// Proper name
1031        Proper,
1032        /// Common noun (or noun compound)
1033        Common,
1034        /// If set, the enum was initialized with an unknown value.
1035        ///
1036        /// Applications can examine the value using [Type::value] or
1037        /// [Type::name].
1038        UnknownValue(r#type::UnknownValue),
1039    }
1040
1041    #[doc(hidden)]
1042    pub mod r#type {
1043        #[allow(unused_imports)]
1044        use super::*;
1045        #[derive(Clone, Debug, PartialEq)]
1046        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1047    }
1048
1049    impl Type {
1050        /// Gets the enum value.
1051        ///
1052        /// Returns `None` if the enum contains an unknown value deserialized from
1053        /// the string representation of enums.
1054        pub fn value(&self) -> std::option::Option<i32> {
1055            match self {
1056                Self::Unknown => std::option::Option::Some(0),
1057                Self::Proper => std::option::Option::Some(1),
1058                Self::Common => std::option::Option::Some(2),
1059                Self::UnknownValue(u) => u.0.value(),
1060            }
1061        }
1062
1063        /// Gets the enum value as a string.
1064        ///
1065        /// Returns `None` if the enum contains an unknown value deserialized from
1066        /// the integer representation of enums.
1067        pub fn name(&self) -> std::option::Option<&str> {
1068            match self {
1069                Self::Unknown => std::option::Option::Some("TYPE_UNKNOWN"),
1070                Self::Proper => std::option::Option::Some("PROPER"),
1071                Self::Common => std::option::Option::Some("COMMON"),
1072                Self::UnknownValue(u) => u.0.name(),
1073            }
1074        }
1075    }
1076
1077    impl std::default::Default for Type {
1078        fn default() -> Self {
1079            use std::convert::From;
1080            Self::from(0)
1081        }
1082    }
1083
1084    impl std::fmt::Display for Type {
1085        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1086            wkt::internal::display_enum(f, self.name(), self.value())
1087        }
1088    }
1089
1090    impl std::convert::From<i32> for Type {
1091        fn from(value: i32) -> Self {
1092            match value {
1093                0 => Self::Unknown,
1094                1 => Self::Proper,
1095                2 => Self::Common,
1096                _ => Self::UnknownValue(r#type::UnknownValue(
1097                    wkt::internal::UnknownEnumValue::Integer(value),
1098                )),
1099            }
1100        }
1101    }
1102
1103    impl std::convert::From<&str> for Type {
1104        fn from(value: &str) -> Self {
1105            use std::string::ToString;
1106            match value {
1107                "TYPE_UNKNOWN" => Self::Unknown,
1108                "PROPER" => Self::Proper,
1109                "COMMON" => Self::Common,
1110                _ => Self::UnknownValue(r#type::UnknownValue(
1111                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1112                )),
1113            }
1114        }
1115    }
1116
1117    impl serde::ser::Serialize for Type {
1118        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1119        where
1120            S: serde::Serializer,
1121        {
1122            match self {
1123                Self::Unknown => serializer.serialize_i32(0),
1124                Self::Proper => serializer.serialize_i32(1),
1125                Self::Common => serializer.serialize_i32(2),
1126                Self::UnknownValue(u) => u.0.serialize(serializer),
1127            }
1128        }
1129    }
1130
1131    impl<'de> serde::de::Deserialize<'de> for Type {
1132        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1133        where
1134            D: serde::Deserializer<'de>,
1135        {
1136            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
1137                ".google.cloud.language.v2.EntityMention.Type",
1138            ))
1139        }
1140    }
1141}
1142
1143/// Represents a text span in the input document.
1144#[derive(Clone, Default, PartialEq)]
1145#[non_exhaustive]
1146pub struct TextSpan {
1147    /// The content of the text span, which is a substring of the document.
1148    pub content: std::string::String,
1149
1150    /// The API calculates the beginning offset of the content in the original
1151    /// document according to the
1152    /// [EncodingType][google.cloud.language.v2.EncodingType] specified in the API
1153    /// request.
1154    ///
1155    /// [google.cloud.language.v2.EncodingType]: crate::model::EncodingType
1156    pub begin_offset: i32,
1157
1158    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1159}
1160
1161impl TextSpan {
1162    /// Creates a new default instance.
1163    pub fn new() -> Self {
1164        std::default::Default::default()
1165    }
1166
1167    /// Sets the value of [content][crate::model::TextSpan::content].
1168    ///
1169    /// # Example
1170    /// ```ignore,no_run
1171    /// # use google_cloud_language_v2::model::TextSpan;
1172    /// let x = TextSpan::new().set_content("example");
1173    /// ```
1174    pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1175        self.content = v.into();
1176        self
1177    }
1178
1179    /// Sets the value of [begin_offset][crate::model::TextSpan::begin_offset].
1180    ///
1181    /// # Example
1182    /// ```ignore,no_run
1183    /// # use google_cloud_language_v2::model::TextSpan;
1184    /// let x = TextSpan::new().set_begin_offset(42);
1185    /// ```
1186    pub fn set_begin_offset<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1187        self.begin_offset = v.into();
1188        self
1189    }
1190}
1191
1192impl wkt::message::Message for TextSpan {
1193    fn typename() -> &'static str {
1194        "type.googleapis.com/google.cloud.language.v2.TextSpan"
1195    }
1196}
1197
1198/// Represents a category returned from the text classifier.
1199#[derive(Clone, Default, PartialEq)]
1200#[non_exhaustive]
1201pub struct ClassificationCategory {
1202    /// The name of the category representing the document.
1203    pub name: std::string::String,
1204
1205    /// The classifier's confidence of the category. Number represents how certain
1206    /// the classifier is that this category represents the given text.
1207    pub confidence: f32,
1208
1209    /// Optional. The classifier's severity of the category. This is only present
1210    /// when the ModerateTextRequest.ModelVersion is set to MODEL_VERSION_2, and
1211    /// the corresponding category has a severity score.
1212    pub severity: f32,
1213
1214    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1215}
1216
1217impl ClassificationCategory {
1218    /// Creates a new default instance.
1219    pub fn new() -> Self {
1220        std::default::Default::default()
1221    }
1222
1223    /// Sets the value of [name][crate::model::ClassificationCategory::name].
1224    ///
1225    /// # Example
1226    /// ```ignore,no_run
1227    /// # use google_cloud_language_v2::model::ClassificationCategory;
1228    /// let x = ClassificationCategory::new().set_name("example");
1229    /// ```
1230    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1231        self.name = v.into();
1232        self
1233    }
1234
1235    /// Sets the value of [confidence][crate::model::ClassificationCategory::confidence].
1236    ///
1237    /// # Example
1238    /// ```ignore,no_run
1239    /// # use google_cloud_language_v2::model::ClassificationCategory;
1240    /// let x = ClassificationCategory::new().set_confidence(42.0);
1241    /// ```
1242    pub fn set_confidence<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
1243        self.confidence = v.into();
1244        self
1245    }
1246
1247    /// Sets the value of [severity][crate::model::ClassificationCategory::severity].
1248    ///
1249    /// # Example
1250    /// ```ignore,no_run
1251    /// # use google_cloud_language_v2::model::ClassificationCategory;
1252    /// let x = ClassificationCategory::new().set_severity(42.0);
1253    /// ```
1254    pub fn set_severity<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
1255        self.severity = v.into();
1256        self
1257    }
1258}
1259
1260impl wkt::message::Message for ClassificationCategory {
1261    fn typename() -> &'static str {
1262        "type.googleapis.com/google.cloud.language.v2.ClassificationCategory"
1263    }
1264}
1265
1266/// The sentiment analysis request message.
1267#[derive(Clone, Default, PartialEq)]
1268#[non_exhaustive]
1269pub struct AnalyzeSentimentRequest {
1270    /// Required. Input document.
1271    pub document: std::option::Option<crate::model::Document>,
1272
1273    /// The encoding type used by the API to calculate sentence offsets.
1274    pub encoding_type: crate::model::EncodingType,
1275
1276    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1277}
1278
1279impl AnalyzeSentimentRequest {
1280    /// Creates a new default instance.
1281    pub fn new() -> Self {
1282        std::default::Default::default()
1283    }
1284
1285    /// Sets the value of [document][crate::model::AnalyzeSentimentRequest::document].
1286    ///
1287    /// # Example
1288    /// ```ignore,no_run
1289    /// # use google_cloud_language_v2::model::AnalyzeSentimentRequest;
1290    /// use google_cloud_language_v2::model::Document;
1291    /// let x = AnalyzeSentimentRequest::new().set_document(Document::default()/* use setters */);
1292    /// ```
1293    pub fn set_document<T>(mut self, v: T) -> Self
1294    where
1295        T: std::convert::Into<crate::model::Document>,
1296    {
1297        self.document = std::option::Option::Some(v.into());
1298        self
1299    }
1300
1301    /// Sets or clears the value of [document][crate::model::AnalyzeSentimentRequest::document].
1302    ///
1303    /// # Example
1304    /// ```ignore,no_run
1305    /// # use google_cloud_language_v2::model::AnalyzeSentimentRequest;
1306    /// use google_cloud_language_v2::model::Document;
1307    /// let x = AnalyzeSentimentRequest::new().set_or_clear_document(Some(Document::default()/* use setters */));
1308    /// let x = AnalyzeSentimentRequest::new().set_or_clear_document(None::<Document>);
1309    /// ```
1310    pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1311    where
1312        T: std::convert::Into<crate::model::Document>,
1313    {
1314        self.document = v.map(|x| x.into());
1315        self
1316    }
1317
1318    /// Sets the value of [encoding_type][crate::model::AnalyzeSentimentRequest::encoding_type].
1319    ///
1320    /// # Example
1321    /// ```ignore,no_run
1322    /// # use google_cloud_language_v2::model::AnalyzeSentimentRequest;
1323    /// use google_cloud_language_v2::model::EncodingType;
1324    /// let x0 = AnalyzeSentimentRequest::new().set_encoding_type(EncodingType::Utf8);
1325    /// let x1 = AnalyzeSentimentRequest::new().set_encoding_type(EncodingType::Utf16);
1326    /// let x2 = AnalyzeSentimentRequest::new().set_encoding_type(EncodingType::Utf32);
1327    /// ```
1328    pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
1329        mut self,
1330        v: T,
1331    ) -> Self {
1332        self.encoding_type = v.into();
1333        self
1334    }
1335}
1336
1337impl wkt::message::Message for AnalyzeSentimentRequest {
1338    fn typename() -> &'static str {
1339        "type.googleapis.com/google.cloud.language.v2.AnalyzeSentimentRequest"
1340    }
1341}
1342
1343/// The sentiment analysis response message.
1344#[derive(Clone, Default, PartialEq)]
1345#[non_exhaustive]
1346pub struct AnalyzeSentimentResponse {
1347    /// The overall sentiment of the input document.
1348    pub document_sentiment: std::option::Option<crate::model::Sentiment>,
1349
1350    /// The language of the text, which will be the same as the language specified
1351    /// in the request or, if not specified, the automatically-detected language.
1352    /// See [Document.language][] field for more details.
1353    pub language_code: std::string::String,
1354
1355    /// The sentiment for all the sentences in the document.
1356    pub sentences: std::vec::Vec<crate::model::Sentence>,
1357
1358    /// Whether the language is officially supported. The API may still return a
1359    /// response when the language is not supported, but it is on a best effort
1360    /// basis.
1361    pub language_supported: bool,
1362
1363    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1364}
1365
1366impl AnalyzeSentimentResponse {
1367    /// Creates a new default instance.
1368    pub fn new() -> Self {
1369        std::default::Default::default()
1370    }
1371
1372    /// Sets the value of [document_sentiment][crate::model::AnalyzeSentimentResponse::document_sentiment].
1373    ///
1374    /// # Example
1375    /// ```ignore,no_run
1376    /// # use google_cloud_language_v2::model::AnalyzeSentimentResponse;
1377    /// use google_cloud_language_v2::model::Sentiment;
1378    /// let x = AnalyzeSentimentResponse::new().set_document_sentiment(Sentiment::default()/* use setters */);
1379    /// ```
1380    pub fn set_document_sentiment<T>(mut self, v: T) -> Self
1381    where
1382        T: std::convert::Into<crate::model::Sentiment>,
1383    {
1384        self.document_sentiment = std::option::Option::Some(v.into());
1385        self
1386    }
1387
1388    /// Sets or clears the value of [document_sentiment][crate::model::AnalyzeSentimentResponse::document_sentiment].
1389    ///
1390    /// # Example
1391    /// ```ignore,no_run
1392    /// # use google_cloud_language_v2::model::AnalyzeSentimentResponse;
1393    /// use google_cloud_language_v2::model::Sentiment;
1394    /// let x = AnalyzeSentimentResponse::new().set_or_clear_document_sentiment(Some(Sentiment::default()/* use setters */));
1395    /// let x = AnalyzeSentimentResponse::new().set_or_clear_document_sentiment(None::<Sentiment>);
1396    /// ```
1397    pub fn set_or_clear_document_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
1398    where
1399        T: std::convert::Into<crate::model::Sentiment>,
1400    {
1401        self.document_sentiment = v.map(|x| x.into());
1402        self
1403    }
1404
1405    /// Sets the value of [language_code][crate::model::AnalyzeSentimentResponse::language_code].
1406    ///
1407    /// # Example
1408    /// ```ignore,no_run
1409    /// # use google_cloud_language_v2::model::AnalyzeSentimentResponse;
1410    /// let x = AnalyzeSentimentResponse::new().set_language_code("example");
1411    /// ```
1412    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1413        self.language_code = v.into();
1414        self
1415    }
1416
1417    /// Sets the value of [sentences][crate::model::AnalyzeSentimentResponse::sentences].
1418    ///
1419    /// # Example
1420    /// ```ignore,no_run
1421    /// # use google_cloud_language_v2::model::AnalyzeSentimentResponse;
1422    /// use google_cloud_language_v2::model::Sentence;
1423    /// let x = AnalyzeSentimentResponse::new()
1424    ///     .set_sentences([
1425    ///         Sentence::default()/* use setters */,
1426    ///         Sentence::default()/* use (different) setters */,
1427    ///     ]);
1428    /// ```
1429    pub fn set_sentences<T, V>(mut self, v: T) -> Self
1430    where
1431        T: std::iter::IntoIterator<Item = V>,
1432        V: std::convert::Into<crate::model::Sentence>,
1433    {
1434        use std::iter::Iterator;
1435        self.sentences = v.into_iter().map(|i| i.into()).collect();
1436        self
1437    }
1438
1439    /// Sets the value of [language_supported][crate::model::AnalyzeSentimentResponse::language_supported].
1440    ///
1441    /// # Example
1442    /// ```ignore,no_run
1443    /// # use google_cloud_language_v2::model::AnalyzeSentimentResponse;
1444    /// let x = AnalyzeSentimentResponse::new().set_language_supported(true);
1445    /// ```
1446    pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1447        self.language_supported = v.into();
1448        self
1449    }
1450}
1451
1452impl wkt::message::Message for AnalyzeSentimentResponse {
1453    fn typename() -> &'static str {
1454        "type.googleapis.com/google.cloud.language.v2.AnalyzeSentimentResponse"
1455    }
1456}
1457
1458/// The entity analysis request message.
1459#[derive(Clone, Default, PartialEq)]
1460#[non_exhaustive]
1461pub struct AnalyzeEntitiesRequest {
1462    /// Required. Input document.
1463    pub document: std::option::Option<crate::model::Document>,
1464
1465    /// The encoding type used by the API to calculate offsets.
1466    pub encoding_type: crate::model::EncodingType,
1467
1468    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1469}
1470
1471impl AnalyzeEntitiesRequest {
1472    /// Creates a new default instance.
1473    pub fn new() -> Self {
1474        std::default::Default::default()
1475    }
1476
1477    /// Sets the value of [document][crate::model::AnalyzeEntitiesRequest::document].
1478    ///
1479    /// # Example
1480    /// ```ignore,no_run
1481    /// # use google_cloud_language_v2::model::AnalyzeEntitiesRequest;
1482    /// use google_cloud_language_v2::model::Document;
1483    /// let x = AnalyzeEntitiesRequest::new().set_document(Document::default()/* use setters */);
1484    /// ```
1485    pub fn set_document<T>(mut self, v: T) -> Self
1486    where
1487        T: std::convert::Into<crate::model::Document>,
1488    {
1489        self.document = std::option::Option::Some(v.into());
1490        self
1491    }
1492
1493    /// Sets or clears the value of [document][crate::model::AnalyzeEntitiesRequest::document].
1494    ///
1495    /// # Example
1496    /// ```ignore,no_run
1497    /// # use google_cloud_language_v2::model::AnalyzeEntitiesRequest;
1498    /// use google_cloud_language_v2::model::Document;
1499    /// let x = AnalyzeEntitiesRequest::new().set_or_clear_document(Some(Document::default()/* use setters */));
1500    /// let x = AnalyzeEntitiesRequest::new().set_or_clear_document(None::<Document>);
1501    /// ```
1502    pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1503    where
1504        T: std::convert::Into<crate::model::Document>,
1505    {
1506        self.document = v.map(|x| x.into());
1507        self
1508    }
1509
1510    /// Sets the value of [encoding_type][crate::model::AnalyzeEntitiesRequest::encoding_type].
1511    ///
1512    /// # Example
1513    /// ```ignore,no_run
1514    /// # use google_cloud_language_v2::model::AnalyzeEntitiesRequest;
1515    /// use google_cloud_language_v2::model::EncodingType;
1516    /// let x0 = AnalyzeEntitiesRequest::new().set_encoding_type(EncodingType::Utf8);
1517    /// let x1 = AnalyzeEntitiesRequest::new().set_encoding_type(EncodingType::Utf16);
1518    /// let x2 = AnalyzeEntitiesRequest::new().set_encoding_type(EncodingType::Utf32);
1519    /// ```
1520    pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
1521        mut self,
1522        v: T,
1523    ) -> Self {
1524        self.encoding_type = v.into();
1525        self
1526    }
1527}
1528
1529impl wkt::message::Message for AnalyzeEntitiesRequest {
1530    fn typename() -> &'static str {
1531        "type.googleapis.com/google.cloud.language.v2.AnalyzeEntitiesRequest"
1532    }
1533}
1534
1535/// The entity analysis response message.
1536#[derive(Clone, Default, PartialEq)]
1537#[non_exhaustive]
1538pub struct AnalyzeEntitiesResponse {
1539    /// The recognized entities in the input document.
1540    pub entities: std::vec::Vec<crate::model::Entity>,
1541
1542    /// The language of the text, which will be the same as the language specified
1543    /// in the request or, if not specified, the automatically-detected language.
1544    /// See [Document.language][] field for more details.
1545    pub language_code: std::string::String,
1546
1547    /// Whether the language is officially supported. The API may still return a
1548    /// response when the language is not supported, but it is on a best effort
1549    /// basis.
1550    pub language_supported: bool,
1551
1552    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1553}
1554
1555impl AnalyzeEntitiesResponse {
1556    /// Creates a new default instance.
1557    pub fn new() -> Self {
1558        std::default::Default::default()
1559    }
1560
1561    /// Sets the value of [entities][crate::model::AnalyzeEntitiesResponse::entities].
1562    ///
1563    /// # Example
1564    /// ```ignore,no_run
1565    /// # use google_cloud_language_v2::model::AnalyzeEntitiesResponse;
1566    /// use google_cloud_language_v2::model::Entity;
1567    /// let x = AnalyzeEntitiesResponse::new()
1568    ///     .set_entities([
1569    ///         Entity::default()/* use setters */,
1570    ///         Entity::default()/* use (different) setters */,
1571    ///     ]);
1572    /// ```
1573    pub fn set_entities<T, V>(mut self, v: T) -> Self
1574    where
1575        T: std::iter::IntoIterator<Item = V>,
1576        V: std::convert::Into<crate::model::Entity>,
1577    {
1578        use std::iter::Iterator;
1579        self.entities = v.into_iter().map(|i| i.into()).collect();
1580        self
1581    }
1582
1583    /// Sets the value of [language_code][crate::model::AnalyzeEntitiesResponse::language_code].
1584    ///
1585    /// # Example
1586    /// ```ignore,no_run
1587    /// # use google_cloud_language_v2::model::AnalyzeEntitiesResponse;
1588    /// let x = AnalyzeEntitiesResponse::new().set_language_code("example");
1589    /// ```
1590    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1591        self.language_code = v.into();
1592        self
1593    }
1594
1595    /// Sets the value of [language_supported][crate::model::AnalyzeEntitiesResponse::language_supported].
1596    ///
1597    /// # Example
1598    /// ```ignore,no_run
1599    /// # use google_cloud_language_v2::model::AnalyzeEntitiesResponse;
1600    /// let x = AnalyzeEntitiesResponse::new().set_language_supported(true);
1601    /// ```
1602    pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1603        self.language_supported = v.into();
1604        self
1605    }
1606}
1607
1608impl wkt::message::Message for AnalyzeEntitiesResponse {
1609    fn typename() -> &'static str {
1610        "type.googleapis.com/google.cloud.language.v2.AnalyzeEntitiesResponse"
1611    }
1612}
1613
1614/// The document classification request message.
1615#[derive(Clone, Default, PartialEq)]
1616#[non_exhaustive]
1617pub struct ClassifyTextRequest {
1618    /// Required. Input document.
1619    pub document: std::option::Option<crate::model::Document>,
1620
1621    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1622}
1623
1624impl ClassifyTextRequest {
1625    /// Creates a new default instance.
1626    pub fn new() -> Self {
1627        std::default::Default::default()
1628    }
1629
1630    /// Sets the value of [document][crate::model::ClassifyTextRequest::document].
1631    ///
1632    /// # Example
1633    /// ```ignore,no_run
1634    /// # use google_cloud_language_v2::model::ClassifyTextRequest;
1635    /// use google_cloud_language_v2::model::Document;
1636    /// let x = ClassifyTextRequest::new().set_document(Document::default()/* use setters */);
1637    /// ```
1638    pub fn set_document<T>(mut self, v: T) -> Self
1639    where
1640        T: std::convert::Into<crate::model::Document>,
1641    {
1642        self.document = std::option::Option::Some(v.into());
1643        self
1644    }
1645
1646    /// Sets or clears the value of [document][crate::model::ClassifyTextRequest::document].
1647    ///
1648    /// # Example
1649    /// ```ignore,no_run
1650    /// # use google_cloud_language_v2::model::ClassifyTextRequest;
1651    /// use google_cloud_language_v2::model::Document;
1652    /// let x = ClassifyTextRequest::new().set_or_clear_document(Some(Document::default()/* use setters */));
1653    /// let x = ClassifyTextRequest::new().set_or_clear_document(None::<Document>);
1654    /// ```
1655    pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1656    where
1657        T: std::convert::Into<crate::model::Document>,
1658    {
1659        self.document = v.map(|x| x.into());
1660        self
1661    }
1662}
1663
1664impl wkt::message::Message for ClassifyTextRequest {
1665    fn typename() -> &'static str {
1666        "type.googleapis.com/google.cloud.language.v2.ClassifyTextRequest"
1667    }
1668}
1669
1670/// The document classification response message.
1671#[derive(Clone, Default, PartialEq)]
1672#[non_exhaustive]
1673pub struct ClassifyTextResponse {
1674    /// Categories representing the input document.
1675    pub categories: std::vec::Vec<crate::model::ClassificationCategory>,
1676
1677    /// The language of the text, which will be the same as the language specified
1678    /// in the request or, if not specified, the automatically-detected language.
1679    /// See [Document.language][] field for more details.
1680    pub language_code: std::string::String,
1681
1682    /// Whether the language is officially supported. The API may still return a
1683    /// response when the language is not supported, but it is on a best effort
1684    /// basis.
1685    pub language_supported: bool,
1686
1687    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1688}
1689
1690impl ClassifyTextResponse {
1691    /// Creates a new default instance.
1692    pub fn new() -> Self {
1693        std::default::Default::default()
1694    }
1695
1696    /// Sets the value of [categories][crate::model::ClassifyTextResponse::categories].
1697    ///
1698    /// # Example
1699    /// ```ignore,no_run
1700    /// # use google_cloud_language_v2::model::ClassifyTextResponse;
1701    /// use google_cloud_language_v2::model::ClassificationCategory;
1702    /// let x = ClassifyTextResponse::new()
1703    ///     .set_categories([
1704    ///         ClassificationCategory::default()/* use setters */,
1705    ///         ClassificationCategory::default()/* use (different) setters */,
1706    ///     ]);
1707    /// ```
1708    pub fn set_categories<T, V>(mut self, v: T) -> Self
1709    where
1710        T: std::iter::IntoIterator<Item = V>,
1711        V: std::convert::Into<crate::model::ClassificationCategory>,
1712    {
1713        use std::iter::Iterator;
1714        self.categories = v.into_iter().map(|i| i.into()).collect();
1715        self
1716    }
1717
1718    /// Sets the value of [language_code][crate::model::ClassifyTextResponse::language_code].
1719    ///
1720    /// # Example
1721    /// ```ignore,no_run
1722    /// # use google_cloud_language_v2::model::ClassifyTextResponse;
1723    /// let x = ClassifyTextResponse::new().set_language_code("example");
1724    /// ```
1725    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1726        self.language_code = v.into();
1727        self
1728    }
1729
1730    /// Sets the value of [language_supported][crate::model::ClassifyTextResponse::language_supported].
1731    ///
1732    /// # Example
1733    /// ```ignore,no_run
1734    /// # use google_cloud_language_v2::model::ClassifyTextResponse;
1735    /// let x = ClassifyTextResponse::new().set_language_supported(true);
1736    /// ```
1737    pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1738        self.language_supported = v.into();
1739        self
1740    }
1741}
1742
1743impl wkt::message::Message for ClassifyTextResponse {
1744    fn typename() -> &'static str {
1745        "type.googleapis.com/google.cloud.language.v2.ClassifyTextResponse"
1746    }
1747}
1748
1749/// The document moderation request message.
1750#[derive(Clone, Default, PartialEq)]
1751#[non_exhaustive]
1752pub struct ModerateTextRequest {
1753    /// Required. Input document.
1754    pub document: std::option::Option<crate::model::Document>,
1755
1756    /// Optional. The model version to use for ModerateText.
1757    pub model_version: crate::model::moderate_text_request::ModelVersion,
1758
1759    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1760}
1761
1762impl ModerateTextRequest {
1763    /// Creates a new default instance.
1764    pub fn new() -> Self {
1765        std::default::Default::default()
1766    }
1767
1768    /// Sets the value of [document][crate::model::ModerateTextRequest::document].
1769    ///
1770    /// # Example
1771    /// ```ignore,no_run
1772    /// # use google_cloud_language_v2::model::ModerateTextRequest;
1773    /// use google_cloud_language_v2::model::Document;
1774    /// let x = ModerateTextRequest::new().set_document(Document::default()/* use setters */);
1775    /// ```
1776    pub fn set_document<T>(mut self, v: T) -> Self
1777    where
1778        T: std::convert::Into<crate::model::Document>,
1779    {
1780        self.document = std::option::Option::Some(v.into());
1781        self
1782    }
1783
1784    /// Sets or clears the value of [document][crate::model::ModerateTextRequest::document].
1785    ///
1786    /// # Example
1787    /// ```ignore,no_run
1788    /// # use google_cloud_language_v2::model::ModerateTextRequest;
1789    /// use google_cloud_language_v2::model::Document;
1790    /// let x = ModerateTextRequest::new().set_or_clear_document(Some(Document::default()/* use setters */));
1791    /// let x = ModerateTextRequest::new().set_or_clear_document(None::<Document>);
1792    /// ```
1793    pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1794    where
1795        T: std::convert::Into<crate::model::Document>,
1796    {
1797        self.document = v.map(|x| x.into());
1798        self
1799    }
1800
1801    /// Sets the value of [model_version][crate::model::ModerateTextRequest::model_version].
1802    ///
1803    /// # Example
1804    /// ```ignore,no_run
1805    /// # use google_cloud_language_v2::model::ModerateTextRequest;
1806    /// use google_cloud_language_v2::model::moderate_text_request::ModelVersion;
1807    /// let x0 = ModerateTextRequest::new().set_model_version(ModelVersion::ModelVersion1);
1808    /// let x1 = ModerateTextRequest::new().set_model_version(ModelVersion::ModelVersion2);
1809    /// ```
1810    pub fn set_model_version<
1811        T: std::convert::Into<crate::model::moderate_text_request::ModelVersion>,
1812    >(
1813        mut self,
1814        v: T,
1815    ) -> Self {
1816        self.model_version = v.into();
1817        self
1818    }
1819}
1820
1821impl wkt::message::Message for ModerateTextRequest {
1822    fn typename() -> &'static str {
1823        "type.googleapis.com/google.cloud.language.v2.ModerateTextRequest"
1824    }
1825}
1826
1827/// Defines additional types related to [ModerateTextRequest].
1828pub mod moderate_text_request {
1829    #[allow(unused_imports)]
1830    use super::*;
1831
1832    /// The model version to use for ModerateText.
1833    ///
1834    /// # Working with unknown values
1835    ///
1836    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1837    /// additional enum variants at any time. Adding new variants is not considered
1838    /// a breaking change. Applications should write their code in anticipation of:
1839    ///
1840    /// - New values appearing in future releases of the client library, **and**
1841    /// - New values received dynamically, without application changes.
1842    ///
1843    /// Please consult the [Working with enums] section in the user guide for some
1844    /// guidelines.
1845    ///
1846    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1847    #[derive(Clone, Debug, PartialEq)]
1848    #[non_exhaustive]
1849    pub enum ModelVersion {
1850        /// The default model version.
1851        Unspecified,
1852        /// Use the v1 model, this model is used by default when not provided.
1853        /// The v1 model only returns probability (confidence) score for each
1854        /// category.
1855        ModelVersion1,
1856        /// Use the v2 model.
1857        /// The v2 model only returns probability (confidence) score for each
1858        /// category, and returns severity score for a subset of the categories.
1859        ModelVersion2,
1860        /// If set, the enum was initialized with an unknown value.
1861        ///
1862        /// Applications can examine the value using [ModelVersion::value] or
1863        /// [ModelVersion::name].
1864        UnknownValue(model_version::UnknownValue),
1865    }
1866
1867    #[doc(hidden)]
1868    pub mod model_version {
1869        #[allow(unused_imports)]
1870        use super::*;
1871        #[derive(Clone, Debug, PartialEq)]
1872        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1873    }
1874
1875    impl ModelVersion {
1876        /// Gets the enum value.
1877        ///
1878        /// Returns `None` if the enum contains an unknown value deserialized from
1879        /// the string representation of enums.
1880        pub fn value(&self) -> std::option::Option<i32> {
1881            match self {
1882                Self::Unspecified => std::option::Option::Some(0),
1883                Self::ModelVersion1 => std::option::Option::Some(1),
1884                Self::ModelVersion2 => std::option::Option::Some(2),
1885                Self::UnknownValue(u) => u.0.value(),
1886            }
1887        }
1888
1889        /// Gets the enum value as a string.
1890        ///
1891        /// Returns `None` if the enum contains an unknown value deserialized from
1892        /// the integer representation of enums.
1893        pub fn name(&self) -> std::option::Option<&str> {
1894            match self {
1895                Self::Unspecified => std::option::Option::Some("MODEL_VERSION_UNSPECIFIED"),
1896                Self::ModelVersion1 => std::option::Option::Some("MODEL_VERSION_1"),
1897                Self::ModelVersion2 => std::option::Option::Some("MODEL_VERSION_2"),
1898                Self::UnknownValue(u) => u.0.name(),
1899            }
1900        }
1901    }
1902
1903    impl std::default::Default for ModelVersion {
1904        fn default() -> Self {
1905            use std::convert::From;
1906            Self::from(0)
1907        }
1908    }
1909
1910    impl std::fmt::Display for ModelVersion {
1911        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1912            wkt::internal::display_enum(f, self.name(), self.value())
1913        }
1914    }
1915
1916    impl std::convert::From<i32> for ModelVersion {
1917        fn from(value: i32) -> Self {
1918            match value {
1919                0 => Self::Unspecified,
1920                1 => Self::ModelVersion1,
1921                2 => Self::ModelVersion2,
1922                _ => Self::UnknownValue(model_version::UnknownValue(
1923                    wkt::internal::UnknownEnumValue::Integer(value),
1924                )),
1925            }
1926        }
1927    }
1928
1929    impl std::convert::From<&str> for ModelVersion {
1930        fn from(value: &str) -> Self {
1931            use std::string::ToString;
1932            match value {
1933                "MODEL_VERSION_UNSPECIFIED" => Self::Unspecified,
1934                "MODEL_VERSION_1" => Self::ModelVersion1,
1935                "MODEL_VERSION_2" => Self::ModelVersion2,
1936                _ => Self::UnknownValue(model_version::UnknownValue(
1937                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1938                )),
1939            }
1940        }
1941    }
1942
1943    impl serde::ser::Serialize for ModelVersion {
1944        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1945        where
1946            S: serde::Serializer,
1947        {
1948            match self {
1949                Self::Unspecified => serializer.serialize_i32(0),
1950                Self::ModelVersion1 => serializer.serialize_i32(1),
1951                Self::ModelVersion2 => serializer.serialize_i32(2),
1952                Self::UnknownValue(u) => u.0.serialize(serializer),
1953            }
1954        }
1955    }
1956
1957    impl<'de> serde::de::Deserialize<'de> for ModelVersion {
1958        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1959        where
1960            D: serde::Deserializer<'de>,
1961        {
1962            deserializer.deserialize_any(wkt::internal::EnumVisitor::<ModelVersion>::new(
1963                ".google.cloud.language.v2.ModerateTextRequest.ModelVersion",
1964            ))
1965        }
1966    }
1967}
1968
1969/// The document moderation response message.
1970#[derive(Clone, Default, PartialEq)]
1971#[non_exhaustive]
1972pub struct ModerateTextResponse {
1973    /// Harmful and sensitive categories representing the input document.
1974    pub moderation_categories: std::vec::Vec<crate::model::ClassificationCategory>,
1975
1976    /// The language of the text, which will be the same as the language specified
1977    /// in the request or, if not specified, the automatically-detected language.
1978    /// See [Document.language][] field for more details.
1979    pub language_code: std::string::String,
1980
1981    /// Whether the language is officially supported. The API may still return a
1982    /// response when the language is not supported, but it is on a best effort
1983    /// basis.
1984    pub language_supported: bool,
1985
1986    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1987}
1988
1989impl ModerateTextResponse {
1990    /// Creates a new default instance.
1991    pub fn new() -> Self {
1992        std::default::Default::default()
1993    }
1994
1995    /// Sets the value of [moderation_categories][crate::model::ModerateTextResponse::moderation_categories].
1996    ///
1997    /// # Example
1998    /// ```ignore,no_run
1999    /// # use google_cloud_language_v2::model::ModerateTextResponse;
2000    /// use google_cloud_language_v2::model::ClassificationCategory;
2001    /// let x = ModerateTextResponse::new()
2002    ///     .set_moderation_categories([
2003    ///         ClassificationCategory::default()/* use setters */,
2004    ///         ClassificationCategory::default()/* use (different) setters */,
2005    ///     ]);
2006    /// ```
2007    pub fn set_moderation_categories<T, V>(mut self, v: T) -> Self
2008    where
2009        T: std::iter::IntoIterator<Item = V>,
2010        V: std::convert::Into<crate::model::ClassificationCategory>,
2011    {
2012        use std::iter::Iterator;
2013        self.moderation_categories = v.into_iter().map(|i| i.into()).collect();
2014        self
2015    }
2016
2017    /// Sets the value of [language_code][crate::model::ModerateTextResponse::language_code].
2018    ///
2019    /// # Example
2020    /// ```ignore,no_run
2021    /// # use google_cloud_language_v2::model::ModerateTextResponse;
2022    /// let x = ModerateTextResponse::new().set_language_code("example");
2023    /// ```
2024    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2025        self.language_code = v.into();
2026        self
2027    }
2028
2029    /// Sets the value of [language_supported][crate::model::ModerateTextResponse::language_supported].
2030    ///
2031    /// # Example
2032    /// ```ignore,no_run
2033    /// # use google_cloud_language_v2::model::ModerateTextResponse;
2034    /// let x = ModerateTextResponse::new().set_language_supported(true);
2035    /// ```
2036    pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2037        self.language_supported = v.into();
2038        self
2039    }
2040}
2041
2042impl wkt::message::Message for ModerateTextResponse {
2043    fn typename() -> &'static str {
2044        "type.googleapis.com/google.cloud.language.v2.ModerateTextResponse"
2045    }
2046}
2047
2048/// The request message for the text annotation API, which can perform multiple
2049/// analysis types in one call.
2050#[derive(Clone, Default, PartialEq)]
2051#[non_exhaustive]
2052pub struct AnnotateTextRequest {
2053    /// Required. Input document.
2054    pub document: std::option::Option<crate::model::Document>,
2055
2056    /// Required. The enabled features.
2057    pub features: std::option::Option<crate::model::annotate_text_request::Features>,
2058
2059    /// The encoding type used by the API to calculate offsets.
2060    pub encoding_type: crate::model::EncodingType,
2061
2062    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2063}
2064
2065impl AnnotateTextRequest {
2066    /// Creates a new default instance.
2067    pub fn new() -> Self {
2068        std::default::Default::default()
2069    }
2070
2071    /// Sets the value of [document][crate::model::AnnotateTextRequest::document].
2072    ///
2073    /// # Example
2074    /// ```ignore,no_run
2075    /// # use google_cloud_language_v2::model::AnnotateTextRequest;
2076    /// use google_cloud_language_v2::model::Document;
2077    /// let x = AnnotateTextRequest::new().set_document(Document::default()/* use setters */);
2078    /// ```
2079    pub fn set_document<T>(mut self, v: T) -> Self
2080    where
2081        T: std::convert::Into<crate::model::Document>,
2082    {
2083        self.document = std::option::Option::Some(v.into());
2084        self
2085    }
2086
2087    /// Sets or clears the value of [document][crate::model::AnnotateTextRequest::document].
2088    ///
2089    /// # Example
2090    /// ```ignore,no_run
2091    /// # use google_cloud_language_v2::model::AnnotateTextRequest;
2092    /// use google_cloud_language_v2::model::Document;
2093    /// let x = AnnotateTextRequest::new().set_or_clear_document(Some(Document::default()/* use setters */));
2094    /// let x = AnnotateTextRequest::new().set_or_clear_document(None::<Document>);
2095    /// ```
2096    pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
2097    where
2098        T: std::convert::Into<crate::model::Document>,
2099    {
2100        self.document = v.map(|x| x.into());
2101        self
2102    }
2103
2104    /// Sets the value of [features][crate::model::AnnotateTextRequest::features].
2105    ///
2106    /// # Example
2107    /// ```ignore,no_run
2108    /// # use google_cloud_language_v2::model::AnnotateTextRequest;
2109    /// use google_cloud_language_v2::model::annotate_text_request::Features;
2110    /// let x = AnnotateTextRequest::new().set_features(Features::default()/* use setters */);
2111    /// ```
2112    pub fn set_features<T>(mut self, v: T) -> Self
2113    where
2114        T: std::convert::Into<crate::model::annotate_text_request::Features>,
2115    {
2116        self.features = std::option::Option::Some(v.into());
2117        self
2118    }
2119
2120    /// Sets or clears the value of [features][crate::model::AnnotateTextRequest::features].
2121    ///
2122    /// # Example
2123    /// ```ignore,no_run
2124    /// # use google_cloud_language_v2::model::AnnotateTextRequest;
2125    /// use google_cloud_language_v2::model::annotate_text_request::Features;
2126    /// let x = AnnotateTextRequest::new().set_or_clear_features(Some(Features::default()/* use setters */));
2127    /// let x = AnnotateTextRequest::new().set_or_clear_features(None::<Features>);
2128    /// ```
2129    pub fn set_or_clear_features<T>(mut self, v: std::option::Option<T>) -> Self
2130    where
2131        T: std::convert::Into<crate::model::annotate_text_request::Features>,
2132    {
2133        self.features = v.map(|x| x.into());
2134        self
2135    }
2136
2137    /// Sets the value of [encoding_type][crate::model::AnnotateTextRequest::encoding_type].
2138    ///
2139    /// # Example
2140    /// ```ignore,no_run
2141    /// # use google_cloud_language_v2::model::AnnotateTextRequest;
2142    /// use google_cloud_language_v2::model::EncodingType;
2143    /// let x0 = AnnotateTextRequest::new().set_encoding_type(EncodingType::Utf8);
2144    /// let x1 = AnnotateTextRequest::new().set_encoding_type(EncodingType::Utf16);
2145    /// let x2 = AnnotateTextRequest::new().set_encoding_type(EncodingType::Utf32);
2146    /// ```
2147    pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
2148        mut self,
2149        v: T,
2150    ) -> Self {
2151        self.encoding_type = v.into();
2152        self
2153    }
2154}
2155
2156impl wkt::message::Message for AnnotateTextRequest {
2157    fn typename() -> &'static str {
2158        "type.googleapis.com/google.cloud.language.v2.AnnotateTextRequest"
2159    }
2160}
2161
2162/// Defines additional types related to [AnnotateTextRequest].
2163pub mod annotate_text_request {
2164    #[allow(unused_imports)]
2165    use super::*;
2166
2167    /// All available features.
2168    /// Setting each one to true will enable that specific analysis for the input.
2169    #[derive(Clone, Default, PartialEq)]
2170    #[non_exhaustive]
2171    pub struct Features {
2172        /// Optional. Extract entities.
2173        pub extract_entities: bool,
2174
2175        /// Optional. Extract document-level sentiment.
2176        pub extract_document_sentiment: bool,
2177
2178        /// Optional. Classify the full document into categories.
2179        pub classify_text: bool,
2180
2181        /// Optional. Moderate the document for harmful and sensitive categories.
2182        pub moderate_text: bool,
2183
2184        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2185    }
2186
2187    impl Features {
2188        /// Creates a new default instance.
2189        pub fn new() -> Self {
2190            std::default::Default::default()
2191        }
2192
2193        /// Sets the value of [extract_entities][crate::model::annotate_text_request::Features::extract_entities].
2194        ///
2195        /// # Example
2196        /// ```ignore,no_run
2197        /// # use google_cloud_language_v2::model::annotate_text_request::Features;
2198        /// let x = Features::new().set_extract_entities(true);
2199        /// ```
2200        pub fn set_extract_entities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2201            self.extract_entities = v.into();
2202            self
2203        }
2204
2205        /// Sets the value of [extract_document_sentiment][crate::model::annotate_text_request::Features::extract_document_sentiment].
2206        ///
2207        /// # Example
2208        /// ```ignore,no_run
2209        /// # use google_cloud_language_v2::model::annotate_text_request::Features;
2210        /// let x = Features::new().set_extract_document_sentiment(true);
2211        /// ```
2212        pub fn set_extract_document_sentiment<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2213            self.extract_document_sentiment = v.into();
2214            self
2215        }
2216
2217        /// Sets the value of [classify_text][crate::model::annotate_text_request::Features::classify_text].
2218        ///
2219        /// # Example
2220        /// ```ignore,no_run
2221        /// # use google_cloud_language_v2::model::annotate_text_request::Features;
2222        /// let x = Features::new().set_classify_text(true);
2223        /// ```
2224        pub fn set_classify_text<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2225            self.classify_text = v.into();
2226            self
2227        }
2228
2229        /// Sets the value of [moderate_text][crate::model::annotate_text_request::Features::moderate_text].
2230        ///
2231        /// # Example
2232        /// ```ignore,no_run
2233        /// # use google_cloud_language_v2::model::annotate_text_request::Features;
2234        /// let x = Features::new().set_moderate_text(true);
2235        /// ```
2236        pub fn set_moderate_text<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2237            self.moderate_text = v.into();
2238            self
2239        }
2240    }
2241
2242    impl wkt::message::Message for Features {
2243        fn typename() -> &'static str {
2244            "type.googleapis.com/google.cloud.language.v2.AnnotateTextRequest.Features"
2245        }
2246    }
2247}
2248
2249/// The text annotations response message.
2250#[derive(Clone, Default, PartialEq)]
2251#[non_exhaustive]
2252pub struct AnnotateTextResponse {
2253    /// Sentences in the input document. Populated if the user enables
2254    /// [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment].
2255    ///
2256    /// [google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment]: crate::model::annotate_text_request::Features::extract_document_sentiment
2257    pub sentences: std::vec::Vec<crate::model::Sentence>,
2258
2259    /// Entities, along with their semantic information, in the input document.
2260    /// Populated if the user enables
2261    /// [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entities]
2262    /// or
2263    /// [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_entity_sentiment].
2264    ///
2265    /// [google.cloud.language.v2.AnnotateTextRequest.Features.extract_entities]: crate::model::annotate_text_request::Features::extract_entities
2266    pub entities: std::vec::Vec<crate::model::Entity>,
2267
2268    /// The overall sentiment for the document. Populated if the user enables
2269    /// [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment].
2270    ///
2271    /// [google.cloud.language.v2.AnnotateTextRequest.Features.extract_document_sentiment]: crate::model::annotate_text_request::Features::extract_document_sentiment
2272    pub document_sentiment: std::option::Option<crate::model::Sentiment>,
2273
2274    /// The language of the text, which will be the same as the language specified
2275    /// in the request or, if not specified, the automatically-detected language.
2276    /// See [Document.language][] field for more details.
2277    pub language_code: std::string::String,
2278
2279    /// Categories identified in the input document.
2280    pub categories: std::vec::Vec<crate::model::ClassificationCategory>,
2281
2282    /// Harmful and sensitive categories identified in the input document.
2283    pub moderation_categories: std::vec::Vec<crate::model::ClassificationCategory>,
2284
2285    /// Whether the language is officially supported by all requested features.
2286    /// The API may still return a response when the language is not supported, but
2287    /// it is on a best effort basis.
2288    pub language_supported: bool,
2289
2290    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2291}
2292
2293impl AnnotateTextResponse {
2294    /// Creates a new default instance.
2295    pub fn new() -> Self {
2296        std::default::Default::default()
2297    }
2298
2299    /// Sets the value of [sentences][crate::model::AnnotateTextResponse::sentences].
2300    ///
2301    /// # Example
2302    /// ```ignore,no_run
2303    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2304    /// use google_cloud_language_v2::model::Sentence;
2305    /// let x = AnnotateTextResponse::new()
2306    ///     .set_sentences([
2307    ///         Sentence::default()/* use setters */,
2308    ///         Sentence::default()/* use (different) setters */,
2309    ///     ]);
2310    /// ```
2311    pub fn set_sentences<T, V>(mut self, v: T) -> Self
2312    where
2313        T: std::iter::IntoIterator<Item = V>,
2314        V: std::convert::Into<crate::model::Sentence>,
2315    {
2316        use std::iter::Iterator;
2317        self.sentences = v.into_iter().map(|i| i.into()).collect();
2318        self
2319    }
2320
2321    /// Sets the value of [entities][crate::model::AnnotateTextResponse::entities].
2322    ///
2323    /// # Example
2324    /// ```ignore,no_run
2325    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2326    /// use google_cloud_language_v2::model::Entity;
2327    /// let x = AnnotateTextResponse::new()
2328    ///     .set_entities([
2329    ///         Entity::default()/* use setters */,
2330    ///         Entity::default()/* use (different) setters */,
2331    ///     ]);
2332    /// ```
2333    pub fn set_entities<T, V>(mut self, v: T) -> Self
2334    where
2335        T: std::iter::IntoIterator<Item = V>,
2336        V: std::convert::Into<crate::model::Entity>,
2337    {
2338        use std::iter::Iterator;
2339        self.entities = v.into_iter().map(|i| i.into()).collect();
2340        self
2341    }
2342
2343    /// Sets the value of [document_sentiment][crate::model::AnnotateTextResponse::document_sentiment].
2344    ///
2345    /// # Example
2346    /// ```ignore,no_run
2347    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2348    /// use google_cloud_language_v2::model::Sentiment;
2349    /// let x = AnnotateTextResponse::new().set_document_sentiment(Sentiment::default()/* use setters */);
2350    /// ```
2351    pub fn set_document_sentiment<T>(mut self, v: T) -> Self
2352    where
2353        T: std::convert::Into<crate::model::Sentiment>,
2354    {
2355        self.document_sentiment = std::option::Option::Some(v.into());
2356        self
2357    }
2358
2359    /// Sets or clears the value of [document_sentiment][crate::model::AnnotateTextResponse::document_sentiment].
2360    ///
2361    /// # Example
2362    /// ```ignore,no_run
2363    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2364    /// use google_cloud_language_v2::model::Sentiment;
2365    /// let x = AnnotateTextResponse::new().set_or_clear_document_sentiment(Some(Sentiment::default()/* use setters */));
2366    /// let x = AnnotateTextResponse::new().set_or_clear_document_sentiment(None::<Sentiment>);
2367    /// ```
2368    pub fn set_or_clear_document_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
2369    where
2370        T: std::convert::Into<crate::model::Sentiment>,
2371    {
2372        self.document_sentiment = v.map(|x| x.into());
2373        self
2374    }
2375
2376    /// Sets the value of [language_code][crate::model::AnnotateTextResponse::language_code].
2377    ///
2378    /// # Example
2379    /// ```ignore,no_run
2380    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2381    /// let x = AnnotateTextResponse::new().set_language_code("example");
2382    /// ```
2383    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2384        self.language_code = v.into();
2385        self
2386    }
2387
2388    /// Sets the value of [categories][crate::model::AnnotateTextResponse::categories].
2389    ///
2390    /// # Example
2391    /// ```ignore,no_run
2392    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2393    /// use google_cloud_language_v2::model::ClassificationCategory;
2394    /// let x = AnnotateTextResponse::new()
2395    ///     .set_categories([
2396    ///         ClassificationCategory::default()/* use setters */,
2397    ///         ClassificationCategory::default()/* use (different) setters */,
2398    ///     ]);
2399    /// ```
2400    pub fn set_categories<T, V>(mut self, v: T) -> Self
2401    where
2402        T: std::iter::IntoIterator<Item = V>,
2403        V: std::convert::Into<crate::model::ClassificationCategory>,
2404    {
2405        use std::iter::Iterator;
2406        self.categories = v.into_iter().map(|i| i.into()).collect();
2407        self
2408    }
2409
2410    /// Sets the value of [moderation_categories][crate::model::AnnotateTextResponse::moderation_categories].
2411    ///
2412    /// # Example
2413    /// ```ignore,no_run
2414    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2415    /// use google_cloud_language_v2::model::ClassificationCategory;
2416    /// let x = AnnotateTextResponse::new()
2417    ///     .set_moderation_categories([
2418    ///         ClassificationCategory::default()/* use setters */,
2419    ///         ClassificationCategory::default()/* use (different) setters */,
2420    ///     ]);
2421    /// ```
2422    pub fn set_moderation_categories<T, V>(mut self, v: T) -> Self
2423    where
2424        T: std::iter::IntoIterator<Item = V>,
2425        V: std::convert::Into<crate::model::ClassificationCategory>,
2426    {
2427        use std::iter::Iterator;
2428        self.moderation_categories = v.into_iter().map(|i| i.into()).collect();
2429        self
2430    }
2431
2432    /// Sets the value of [language_supported][crate::model::AnnotateTextResponse::language_supported].
2433    ///
2434    /// # Example
2435    /// ```ignore,no_run
2436    /// # use google_cloud_language_v2::model::AnnotateTextResponse;
2437    /// let x = AnnotateTextResponse::new().set_language_supported(true);
2438    /// ```
2439    pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2440        self.language_supported = v.into();
2441        self
2442    }
2443}
2444
2445impl wkt::message::Message for AnnotateTextResponse {
2446    fn typename() -> &'static str {
2447        "type.googleapis.com/google.cloud.language.v2.AnnotateTextResponse"
2448    }
2449}
2450
2451/// Represents the text encoding that the caller uses to process the output.
2452/// Providing an `EncodingType` is recommended because the API provides the
2453/// beginning offsets for various outputs, such as tokens and mentions, and
2454/// languages that natively use different text encodings may access offsets
2455/// differently.
2456///
2457/// # Working with unknown values
2458///
2459/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2460/// additional enum variants at any time. Adding new variants is not considered
2461/// a breaking change. Applications should write their code in anticipation of:
2462///
2463/// - New values appearing in future releases of the client library, **and**
2464/// - New values received dynamically, without application changes.
2465///
2466/// Please consult the [Working with enums] section in the user guide for some
2467/// guidelines.
2468///
2469/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2470#[derive(Clone, Debug, PartialEq)]
2471#[non_exhaustive]
2472pub enum EncodingType {
2473    /// If `EncodingType` is not specified, encoding-dependent information (such as
2474    /// `begin_offset`) will be set at `-1`.
2475    None,
2476    /// Encoding-dependent information (such as `begin_offset`) is calculated based
2477    /// on the UTF-8 encoding of the input. C++ and Go are examples of languages
2478    /// that use this encoding natively.
2479    Utf8,
2480    /// Encoding-dependent information (such as `begin_offset`) is calculated based
2481    /// on the UTF-16 encoding of the input. Java and JavaScript are examples of
2482    /// languages that use this encoding natively.
2483    Utf16,
2484    /// Encoding-dependent information (such as `begin_offset`) is calculated based
2485    /// on the UTF-32 encoding of the input. Python is an example of a language
2486    /// that uses this encoding natively.
2487    Utf32,
2488    /// If set, the enum was initialized with an unknown value.
2489    ///
2490    /// Applications can examine the value using [EncodingType::value] or
2491    /// [EncodingType::name].
2492    UnknownValue(encoding_type::UnknownValue),
2493}
2494
2495#[doc(hidden)]
2496pub mod encoding_type {
2497    #[allow(unused_imports)]
2498    use super::*;
2499    #[derive(Clone, Debug, PartialEq)]
2500    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2501}
2502
2503impl EncodingType {
2504    /// Gets the enum value.
2505    ///
2506    /// Returns `None` if the enum contains an unknown value deserialized from
2507    /// the string representation of enums.
2508    pub fn value(&self) -> std::option::Option<i32> {
2509        match self {
2510            Self::None => std::option::Option::Some(0),
2511            Self::Utf8 => std::option::Option::Some(1),
2512            Self::Utf16 => std::option::Option::Some(2),
2513            Self::Utf32 => std::option::Option::Some(3),
2514            Self::UnknownValue(u) => u.0.value(),
2515        }
2516    }
2517
2518    /// Gets the enum value as a string.
2519    ///
2520    /// Returns `None` if the enum contains an unknown value deserialized from
2521    /// the integer representation of enums.
2522    pub fn name(&self) -> std::option::Option<&str> {
2523        match self {
2524            Self::None => std::option::Option::Some("NONE"),
2525            Self::Utf8 => std::option::Option::Some("UTF8"),
2526            Self::Utf16 => std::option::Option::Some("UTF16"),
2527            Self::Utf32 => std::option::Option::Some("UTF32"),
2528            Self::UnknownValue(u) => u.0.name(),
2529        }
2530    }
2531}
2532
2533impl std::default::Default for EncodingType {
2534    fn default() -> Self {
2535        use std::convert::From;
2536        Self::from(0)
2537    }
2538}
2539
2540impl std::fmt::Display for EncodingType {
2541    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2542        wkt::internal::display_enum(f, self.name(), self.value())
2543    }
2544}
2545
2546impl std::convert::From<i32> for EncodingType {
2547    fn from(value: i32) -> Self {
2548        match value {
2549            0 => Self::None,
2550            1 => Self::Utf8,
2551            2 => Self::Utf16,
2552            3 => Self::Utf32,
2553            _ => Self::UnknownValue(encoding_type::UnknownValue(
2554                wkt::internal::UnknownEnumValue::Integer(value),
2555            )),
2556        }
2557    }
2558}
2559
2560impl std::convert::From<&str> for EncodingType {
2561    fn from(value: &str) -> Self {
2562        use std::string::ToString;
2563        match value {
2564            "NONE" => Self::None,
2565            "UTF8" => Self::Utf8,
2566            "UTF16" => Self::Utf16,
2567            "UTF32" => Self::Utf32,
2568            _ => Self::UnknownValue(encoding_type::UnknownValue(
2569                wkt::internal::UnknownEnumValue::String(value.to_string()),
2570            )),
2571        }
2572    }
2573}
2574
2575impl serde::ser::Serialize for EncodingType {
2576    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2577    where
2578        S: serde::Serializer,
2579    {
2580        match self {
2581            Self::None => serializer.serialize_i32(0),
2582            Self::Utf8 => serializer.serialize_i32(1),
2583            Self::Utf16 => serializer.serialize_i32(2),
2584            Self::Utf32 => serializer.serialize_i32(3),
2585            Self::UnknownValue(u) => u.0.serialize(serializer),
2586        }
2587    }
2588}
2589
2590impl<'de> serde::de::Deserialize<'de> for EncodingType {
2591    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2592    where
2593        D: serde::Deserializer<'de>,
2594    {
2595        deserializer.deserialize_any(wkt::internal::EnumVisitor::<EncodingType>::new(
2596            ".google.cloud.language.v2.EncodingType",
2597        ))
2598    }
2599}