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