1#![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
33#[serde_with::serde_as]
35#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
36#[serde(default, rename_all = "camelCase")]
37#[non_exhaustive]
38pub struct Document {
39 #[serde(rename = "type")]
42 pub r#type: crate::model::document::Type,
43
44 #[serde(skip_serializing_if = "std::string::String::is_empty")]
53 pub language_code: std::string::String,
54
55 #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")]
58 pub source: std::option::Option<crate::model::document::Source>,
59
60 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
61 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
62}
63
64impl Document {
65 pub fn new() -> Self {
66 std::default::Default::default()
67 }
68
69 pub fn set_type<T: std::convert::Into<crate::model::document::Type>>(mut self, v: T) -> Self {
71 self.r#type = v.into();
72 self
73 }
74
75 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
77 self.language_code = v.into();
78 self
79 }
80
81 pub fn set_source<
86 T: std::convert::Into<std::option::Option<crate::model::document::Source>>,
87 >(
88 mut self,
89 v: T,
90 ) -> Self {
91 self.source = v.into();
92 self
93 }
94
95 pub fn content(&self) -> std::option::Option<&std::string::String> {
99 #[allow(unreachable_patterns)]
100 self.source.as_ref().and_then(|v| match v {
101 crate::model::document::Source::Content(v) => std::option::Option::Some(v),
102 _ => std::option::Option::None,
103 })
104 }
105
106 pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
112 self.source = std::option::Option::Some(crate::model::document::Source::Content(v.into()));
113 self
114 }
115
116 pub fn gcs_content_uri(&self) -> std::option::Option<&std::string::String> {
120 #[allow(unreachable_patterns)]
121 self.source.as_ref().and_then(|v| match v {
122 crate::model::document::Source::GcsContentUri(v) => std::option::Option::Some(v),
123 _ => std::option::Option::None,
124 })
125 }
126
127 pub fn set_gcs_content_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
133 self.source =
134 std::option::Option::Some(crate::model::document::Source::GcsContentUri(v.into()));
135 self
136 }
137}
138
139impl wkt::message::Message for Document {
140 fn typename() -> &'static str {
141 "type.googleapis.com/google.cloud.language.v2.Document"
142 }
143}
144
145pub mod document {
147 #[allow(unused_imports)]
148 use super::*;
149
150 #[derive(Clone, Debug, PartialEq)]
166 #[non_exhaustive]
167 pub enum Type {
168 Unspecified,
170 PlainText,
172 Html,
174 UnknownValue(r#type::UnknownValue),
179 }
180
181 #[doc(hidden)]
182 pub mod r#type {
183 #[allow(unused_imports)]
184 use super::*;
185 #[derive(Clone, Debug, PartialEq)]
186 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
187 }
188
189 impl Type {
190 pub fn value(&self) -> std::option::Option<i32> {
195 match self {
196 Self::Unspecified => std::option::Option::Some(0),
197 Self::PlainText => std::option::Option::Some(1),
198 Self::Html => std::option::Option::Some(2),
199 Self::UnknownValue(u) => u.0.value(),
200 }
201 }
202
203 pub fn name(&self) -> std::option::Option<&str> {
208 match self {
209 Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
210 Self::PlainText => std::option::Option::Some("PLAIN_TEXT"),
211 Self::Html => std::option::Option::Some("HTML"),
212 Self::UnknownValue(u) => u.0.name(),
213 }
214 }
215 }
216
217 impl std::default::Default for Type {
218 fn default() -> Self {
219 use std::convert::From;
220 Self::from(0)
221 }
222 }
223
224 impl std::fmt::Display for Type {
225 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
226 wkt::internal::display_enum(f, self.name(), self.value())
227 }
228 }
229
230 impl std::convert::From<i32> for Type {
231 fn from(value: i32) -> Self {
232 match value {
233 0 => Self::Unspecified,
234 1 => Self::PlainText,
235 2 => Self::Html,
236 _ => Self::UnknownValue(r#type::UnknownValue(
237 wkt::internal::UnknownEnumValue::Integer(value),
238 )),
239 }
240 }
241 }
242
243 impl std::convert::From<&str> for Type {
244 fn from(value: &str) -> Self {
245 use std::string::ToString;
246 match value {
247 "TYPE_UNSPECIFIED" => Self::Unspecified,
248 "PLAIN_TEXT" => Self::PlainText,
249 "HTML" => Self::Html,
250 _ => Self::UnknownValue(r#type::UnknownValue(
251 wkt::internal::UnknownEnumValue::String(value.to_string()),
252 )),
253 }
254 }
255 }
256
257 impl serde::ser::Serialize for Type {
258 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
259 where
260 S: serde::Serializer,
261 {
262 match self {
263 Self::Unspecified => serializer.serialize_i32(0),
264 Self::PlainText => serializer.serialize_i32(1),
265 Self::Html => serializer.serialize_i32(2),
266 Self::UnknownValue(u) => u.0.serialize(serializer),
267 }
268 }
269 }
270
271 impl<'de> serde::de::Deserialize<'de> for Type {
272 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
273 where
274 D: serde::Deserializer<'de>,
275 {
276 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
277 ".google.cloud.language.v2.Document.Type",
278 ))
279 }
280 }
281
282 #[serde_with::serde_as]
285 #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
286 #[serde(rename_all = "camelCase")]
287 #[non_exhaustive]
288 pub enum Source {
289 Content(std::string::String),
292 GcsContentUri(std::string::String),
297 }
298}
299
300#[serde_with::serde_as]
302#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
303#[serde(default, rename_all = "camelCase")]
304#[non_exhaustive]
305pub struct Sentence {
306 #[serde(skip_serializing_if = "std::option::Option::is_none")]
308 pub text: std::option::Option<crate::model::TextSpan>,
309
310 #[serde(skip_serializing_if = "std::option::Option::is_none")]
316 pub sentiment: std::option::Option<crate::model::Sentiment>,
317
318 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
319 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
320}
321
322impl Sentence {
323 pub fn new() -> Self {
324 std::default::Default::default()
325 }
326
327 pub fn set_text<T: std::convert::Into<std::option::Option<crate::model::TextSpan>>>(
329 mut self,
330 v: T,
331 ) -> Self {
332 self.text = v.into();
333 self
334 }
335
336 pub fn set_sentiment<T: std::convert::Into<std::option::Option<crate::model::Sentiment>>>(
338 mut self,
339 v: T,
340 ) -> Self {
341 self.sentiment = v.into();
342 self
343 }
344}
345
346impl wkt::message::Message for Sentence {
347 fn typename() -> &'static str {
348 "type.googleapis.com/google.cloud.language.v2.Sentence"
349 }
350}
351
352#[serde_with::serde_as]
356#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
357#[serde(default, rename_all = "camelCase")]
358#[non_exhaustive]
359pub struct Entity {
360 #[serde(skip_serializing_if = "std::string::String::is_empty")]
362 pub name: std::string::String,
363
364 #[serde(rename = "type")]
366 pub r#type: crate::model::entity::Type,
367
368 #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
373 pub metadata: std::collections::HashMap<std::string::String, std::string::String>,
374
375 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
378 pub mentions: std::vec::Vec<crate::model::EntityMention>,
379
380 #[serde(skip_serializing_if = "std::option::Option::is_none")]
385 pub sentiment: std::option::Option<crate::model::Sentiment>,
386
387 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
388 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
389}
390
391impl Entity {
392 pub fn new() -> Self {
393 std::default::Default::default()
394 }
395
396 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
398 self.name = v.into();
399 self
400 }
401
402 pub fn set_type<T: std::convert::Into<crate::model::entity::Type>>(mut self, v: T) -> Self {
404 self.r#type = v.into();
405 self
406 }
407
408 pub fn set_metadata<T, K, V>(mut self, v: T) -> Self
410 where
411 T: std::iter::IntoIterator<Item = (K, V)>,
412 K: std::convert::Into<std::string::String>,
413 V: std::convert::Into<std::string::String>,
414 {
415 use std::iter::Iterator;
416 self.metadata = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
417 self
418 }
419
420 pub fn set_mentions<T, V>(mut self, v: T) -> Self
422 where
423 T: std::iter::IntoIterator<Item = V>,
424 V: std::convert::Into<crate::model::EntityMention>,
425 {
426 use std::iter::Iterator;
427 self.mentions = v.into_iter().map(|i| i.into()).collect();
428 self
429 }
430
431 pub fn set_sentiment<T: std::convert::Into<std::option::Option<crate::model::Sentiment>>>(
433 mut self,
434 v: T,
435 ) -> Self {
436 self.sentiment = v.into();
437 self
438 }
439}
440
441impl wkt::message::Message for Entity {
442 fn typename() -> &'static str {
443 "type.googleapis.com/google.cloud.language.v2.Entity"
444 }
445}
446
447pub mod entity {
449 #[allow(unused_imports)]
450 use super::*;
451
452 #[derive(Clone, Debug, PartialEq)]
470 #[non_exhaustive]
471 pub enum Type {
472 Unknown,
474 Person,
476 Location,
478 Organization,
480 Event,
482 WorkOfArt,
484 ConsumerGood,
486 Other,
488 PhoneNumber,
500 Address,
516 Date,
524 Number,
528 Price,
532 UnknownValue(r#type::UnknownValue),
537 }
538
539 #[doc(hidden)]
540 pub mod r#type {
541 #[allow(unused_imports)]
542 use super::*;
543 #[derive(Clone, Debug, PartialEq)]
544 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
545 }
546
547 impl Type {
548 pub fn value(&self) -> std::option::Option<i32> {
553 match self {
554 Self::Unknown => std::option::Option::Some(0),
555 Self::Person => std::option::Option::Some(1),
556 Self::Location => std::option::Option::Some(2),
557 Self::Organization => std::option::Option::Some(3),
558 Self::Event => std::option::Option::Some(4),
559 Self::WorkOfArt => std::option::Option::Some(5),
560 Self::ConsumerGood => std::option::Option::Some(6),
561 Self::Other => std::option::Option::Some(7),
562 Self::PhoneNumber => std::option::Option::Some(9),
563 Self::Address => std::option::Option::Some(10),
564 Self::Date => std::option::Option::Some(11),
565 Self::Number => std::option::Option::Some(12),
566 Self::Price => std::option::Option::Some(13),
567 Self::UnknownValue(u) => u.0.value(),
568 }
569 }
570
571 pub fn name(&self) -> std::option::Option<&str> {
576 match self {
577 Self::Unknown => std::option::Option::Some("UNKNOWN"),
578 Self::Person => std::option::Option::Some("PERSON"),
579 Self::Location => std::option::Option::Some("LOCATION"),
580 Self::Organization => std::option::Option::Some("ORGANIZATION"),
581 Self::Event => std::option::Option::Some("EVENT"),
582 Self::WorkOfArt => std::option::Option::Some("WORK_OF_ART"),
583 Self::ConsumerGood => std::option::Option::Some("CONSUMER_GOOD"),
584 Self::Other => std::option::Option::Some("OTHER"),
585 Self::PhoneNumber => std::option::Option::Some("PHONE_NUMBER"),
586 Self::Address => std::option::Option::Some("ADDRESS"),
587 Self::Date => std::option::Option::Some("DATE"),
588 Self::Number => std::option::Option::Some("NUMBER"),
589 Self::Price => std::option::Option::Some("PRICE"),
590 Self::UnknownValue(u) => u.0.name(),
591 }
592 }
593 }
594
595 impl std::default::Default for Type {
596 fn default() -> Self {
597 use std::convert::From;
598 Self::from(0)
599 }
600 }
601
602 impl std::fmt::Display for Type {
603 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
604 wkt::internal::display_enum(f, self.name(), self.value())
605 }
606 }
607
608 impl std::convert::From<i32> for Type {
609 fn from(value: i32) -> Self {
610 match value {
611 0 => Self::Unknown,
612 1 => Self::Person,
613 2 => Self::Location,
614 3 => Self::Organization,
615 4 => Self::Event,
616 5 => Self::WorkOfArt,
617 6 => Self::ConsumerGood,
618 7 => Self::Other,
619 9 => Self::PhoneNumber,
620 10 => Self::Address,
621 11 => Self::Date,
622 12 => Self::Number,
623 13 => Self::Price,
624 _ => Self::UnknownValue(r#type::UnknownValue(
625 wkt::internal::UnknownEnumValue::Integer(value),
626 )),
627 }
628 }
629 }
630
631 impl std::convert::From<&str> for Type {
632 fn from(value: &str) -> Self {
633 use std::string::ToString;
634 match value {
635 "UNKNOWN" => Self::Unknown,
636 "PERSON" => Self::Person,
637 "LOCATION" => Self::Location,
638 "ORGANIZATION" => Self::Organization,
639 "EVENT" => Self::Event,
640 "WORK_OF_ART" => Self::WorkOfArt,
641 "CONSUMER_GOOD" => Self::ConsumerGood,
642 "OTHER" => Self::Other,
643 "PHONE_NUMBER" => Self::PhoneNumber,
644 "ADDRESS" => Self::Address,
645 "DATE" => Self::Date,
646 "NUMBER" => Self::Number,
647 "PRICE" => Self::Price,
648 _ => Self::UnknownValue(r#type::UnknownValue(
649 wkt::internal::UnknownEnumValue::String(value.to_string()),
650 )),
651 }
652 }
653 }
654
655 impl serde::ser::Serialize for Type {
656 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
657 where
658 S: serde::Serializer,
659 {
660 match self {
661 Self::Unknown => serializer.serialize_i32(0),
662 Self::Person => serializer.serialize_i32(1),
663 Self::Location => serializer.serialize_i32(2),
664 Self::Organization => serializer.serialize_i32(3),
665 Self::Event => serializer.serialize_i32(4),
666 Self::WorkOfArt => serializer.serialize_i32(5),
667 Self::ConsumerGood => serializer.serialize_i32(6),
668 Self::Other => serializer.serialize_i32(7),
669 Self::PhoneNumber => serializer.serialize_i32(9),
670 Self::Address => serializer.serialize_i32(10),
671 Self::Date => serializer.serialize_i32(11),
672 Self::Number => serializer.serialize_i32(12),
673 Self::Price => serializer.serialize_i32(13),
674 Self::UnknownValue(u) => u.0.serialize(serializer),
675 }
676 }
677 }
678
679 impl<'de> serde::de::Deserialize<'de> for Type {
680 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
681 where
682 D: serde::Deserializer<'de>,
683 {
684 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
685 ".google.cloud.language.v2.Entity.Type",
686 ))
687 }
688 }
689}
690
691#[serde_with::serde_as]
694#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
695#[serde(default, rename_all = "camelCase")]
696#[non_exhaustive]
697pub struct Sentiment {
698 #[serde(skip_serializing_if = "wkt::internal::is_default")]
702 #[serde_as(as = "wkt::internal::F32")]
703 pub magnitude: f32,
704
705 #[serde(skip_serializing_if = "wkt::internal::is_default")]
708 #[serde_as(as = "wkt::internal::F32")]
709 pub score: f32,
710
711 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
712 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
713}
714
715impl Sentiment {
716 pub fn new() -> Self {
717 std::default::Default::default()
718 }
719
720 pub fn set_magnitude<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
722 self.magnitude = v.into();
723 self
724 }
725
726 pub fn set_score<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
728 self.score = v.into();
729 self
730 }
731}
732
733impl wkt::message::Message for Sentiment {
734 fn typename() -> &'static str {
735 "type.googleapis.com/google.cloud.language.v2.Sentiment"
736 }
737}
738
739#[serde_with::serde_as]
742#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
743#[serde(default, rename_all = "camelCase")]
744#[non_exhaustive]
745pub struct EntityMention {
746 #[serde(skip_serializing_if = "std::option::Option::is_none")]
748 pub text: std::option::Option<crate::model::TextSpan>,
749
750 #[serde(rename = "type")]
752 pub r#type: crate::model::entity_mention::Type,
753
754 #[serde(skip_serializing_if = "std::option::Option::is_none")]
759 pub sentiment: std::option::Option<crate::model::Sentiment>,
760
761 #[serde(skip_serializing_if = "wkt::internal::is_default")]
766 #[serde_as(as = "wkt::internal::F32")]
767 pub probability: f32,
768
769 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
770 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
771}
772
773impl EntityMention {
774 pub fn new() -> Self {
775 std::default::Default::default()
776 }
777
778 pub fn set_text<T: std::convert::Into<std::option::Option<crate::model::TextSpan>>>(
780 mut self,
781 v: T,
782 ) -> Self {
783 self.text = v.into();
784 self
785 }
786
787 pub fn set_type<T: std::convert::Into<crate::model::entity_mention::Type>>(
789 mut self,
790 v: T,
791 ) -> Self {
792 self.r#type = v.into();
793 self
794 }
795
796 pub fn set_sentiment<T: std::convert::Into<std::option::Option<crate::model::Sentiment>>>(
798 mut self,
799 v: T,
800 ) -> Self {
801 self.sentiment = v.into();
802 self
803 }
804
805 pub fn set_probability<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
807 self.probability = v.into();
808 self
809 }
810}
811
812impl wkt::message::Message for EntityMention {
813 fn typename() -> &'static str {
814 "type.googleapis.com/google.cloud.language.v2.EntityMention"
815 }
816}
817
818pub mod entity_mention {
820 #[allow(unused_imports)]
821 use super::*;
822
823 #[derive(Clone, Debug, PartialEq)]
839 #[non_exhaustive]
840 pub enum Type {
841 Unknown,
843 Proper,
845 Common,
847 UnknownValue(r#type::UnknownValue),
852 }
853
854 #[doc(hidden)]
855 pub mod r#type {
856 #[allow(unused_imports)]
857 use super::*;
858 #[derive(Clone, Debug, PartialEq)]
859 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
860 }
861
862 impl Type {
863 pub fn value(&self) -> std::option::Option<i32> {
868 match self {
869 Self::Unknown => std::option::Option::Some(0),
870 Self::Proper => std::option::Option::Some(1),
871 Self::Common => std::option::Option::Some(2),
872 Self::UnknownValue(u) => u.0.value(),
873 }
874 }
875
876 pub fn name(&self) -> std::option::Option<&str> {
881 match self {
882 Self::Unknown => std::option::Option::Some("TYPE_UNKNOWN"),
883 Self::Proper => std::option::Option::Some("PROPER"),
884 Self::Common => std::option::Option::Some("COMMON"),
885 Self::UnknownValue(u) => u.0.name(),
886 }
887 }
888 }
889
890 impl std::default::Default for Type {
891 fn default() -> Self {
892 use std::convert::From;
893 Self::from(0)
894 }
895 }
896
897 impl std::fmt::Display for Type {
898 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
899 wkt::internal::display_enum(f, self.name(), self.value())
900 }
901 }
902
903 impl std::convert::From<i32> for Type {
904 fn from(value: i32) -> Self {
905 match value {
906 0 => Self::Unknown,
907 1 => Self::Proper,
908 2 => Self::Common,
909 _ => Self::UnknownValue(r#type::UnknownValue(
910 wkt::internal::UnknownEnumValue::Integer(value),
911 )),
912 }
913 }
914 }
915
916 impl std::convert::From<&str> for Type {
917 fn from(value: &str) -> Self {
918 use std::string::ToString;
919 match value {
920 "TYPE_UNKNOWN" => Self::Unknown,
921 "PROPER" => Self::Proper,
922 "COMMON" => Self::Common,
923 _ => Self::UnknownValue(r#type::UnknownValue(
924 wkt::internal::UnknownEnumValue::String(value.to_string()),
925 )),
926 }
927 }
928 }
929
930 impl serde::ser::Serialize for Type {
931 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
932 where
933 S: serde::Serializer,
934 {
935 match self {
936 Self::Unknown => serializer.serialize_i32(0),
937 Self::Proper => serializer.serialize_i32(1),
938 Self::Common => serializer.serialize_i32(2),
939 Self::UnknownValue(u) => u.0.serialize(serializer),
940 }
941 }
942 }
943
944 impl<'de> serde::de::Deserialize<'de> for Type {
945 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
946 where
947 D: serde::Deserializer<'de>,
948 {
949 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
950 ".google.cloud.language.v2.EntityMention.Type",
951 ))
952 }
953 }
954}
955
956#[serde_with::serde_as]
958#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
959#[serde(default, rename_all = "camelCase")]
960#[non_exhaustive]
961pub struct TextSpan {
962 #[serde(skip_serializing_if = "std::string::String::is_empty")]
964 pub content: std::string::String,
965
966 #[serde(skip_serializing_if = "wkt::internal::is_default")]
973 pub begin_offset: i32,
974
975 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
976 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
977}
978
979impl TextSpan {
980 pub fn new() -> Self {
981 std::default::Default::default()
982 }
983
984 pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
986 self.content = v.into();
987 self
988 }
989
990 pub fn set_begin_offset<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
992 self.begin_offset = v.into();
993 self
994 }
995}
996
997impl wkt::message::Message for TextSpan {
998 fn typename() -> &'static str {
999 "type.googleapis.com/google.cloud.language.v2.TextSpan"
1000 }
1001}
1002
1003#[serde_with::serde_as]
1005#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1006#[serde(default, rename_all = "camelCase")]
1007#[non_exhaustive]
1008pub struct ClassificationCategory {
1009 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1011 pub name: std::string::String,
1012
1013 #[serde(skip_serializing_if = "wkt::internal::is_default")]
1016 #[serde_as(as = "wkt::internal::F32")]
1017 pub confidence: f32,
1018
1019 #[serde(skip_serializing_if = "wkt::internal::is_default")]
1023 #[serde_as(as = "wkt::internal::F32")]
1024 pub severity: f32,
1025
1026 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1027 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1028}
1029
1030impl ClassificationCategory {
1031 pub fn new() -> Self {
1032 std::default::Default::default()
1033 }
1034
1035 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1037 self.name = v.into();
1038 self
1039 }
1040
1041 pub fn set_confidence<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
1043 self.confidence = v.into();
1044 self
1045 }
1046
1047 pub fn set_severity<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
1049 self.severity = v.into();
1050 self
1051 }
1052}
1053
1054impl wkt::message::Message for ClassificationCategory {
1055 fn typename() -> &'static str {
1056 "type.googleapis.com/google.cloud.language.v2.ClassificationCategory"
1057 }
1058}
1059
1060#[serde_with::serde_as]
1062#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1063#[serde(default, rename_all = "camelCase")]
1064#[non_exhaustive]
1065pub struct AnalyzeSentimentRequest {
1066 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1068 pub document: std::option::Option<crate::model::Document>,
1069
1070 pub encoding_type: crate::model::EncodingType,
1072
1073 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1074 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1075}
1076
1077impl AnalyzeSentimentRequest {
1078 pub fn new() -> Self {
1079 std::default::Default::default()
1080 }
1081
1082 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
1084 mut self,
1085 v: T,
1086 ) -> Self {
1087 self.document = v.into();
1088 self
1089 }
1090
1091 pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
1093 mut self,
1094 v: T,
1095 ) -> Self {
1096 self.encoding_type = v.into();
1097 self
1098 }
1099}
1100
1101impl wkt::message::Message for AnalyzeSentimentRequest {
1102 fn typename() -> &'static str {
1103 "type.googleapis.com/google.cloud.language.v2.AnalyzeSentimentRequest"
1104 }
1105}
1106
1107#[serde_with::serde_as]
1109#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1110#[serde(default, rename_all = "camelCase")]
1111#[non_exhaustive]
1112pub struct AnalyzeSentimentResponse {
1113 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1115 pub document_sentiment: std::option::Option<crate::model::Sentiment>,
1116
1117 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1121 pub language_code: std::string::String,
1122
1123 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1125 pub sentences: std::vec::Vec<crate::model::Sentence>,
1126
1127 #[serde(skip_serializing_if = "wkt::internal::is_default")]
1131 pub language_supported: bool,
1132
1133 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1134 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1135}
1136
1137impl AnalyzeSentimentResponse {
1138 pub fn new() -> Self {
1139 std::default::Default::default()
1140 }
1141
1142 pub fn set_document_sentiment<
1144 T: std::convert::Into<std::option::Option<crate::model::Sentiment>>,
1145 >(
1146 mut self,
1147 v: T,
1148 ) -> Self {
1149 self.document_sentiment = v.into();
1150 self
1151 }
1152
1153 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1155 self.language_code = v.into();
1156 self
1157 }
1158
1159 pub fn set_sentences<T, V>(mut self, v: T) -> Self
1161 where
1162 T: std::iter::IntoIterator<Item = V>,
1163 V: std::convert::Into<crate::model::Sentence>,
1164 {
1165 use std::iter::Iterator;
1166 self.sentences = v.into_iter().map(|i| i.into()).collect();
1167 self
1168 }
1169
1170 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1172 self.language_supported = v.into();
1173 self
1174 }
1175}
1176
1177impl wkt::message::Message for AnalyzeSentimentResponse {
1178 fn typename() -> &'static str {
1179 "type.googleapis.com/google.cloud.language.v2.AnalyzeSentimentResponse"
1180 }
1181}
1182
1183#[serde_with::serde_as]
1185#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1186#[serde(default, rename_all = "camelCase")]
1187#[non_exhaustive]
1188pub struct AnalyzeEntitiesRequest {
1189 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1191 pub document: std::option::Option<crate::model::Document>,
1192
1193 pub encoding_type: crate::model::EncodingType,
1195
1196 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1197 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1198}
1199
1200impl AnalyzeEntitiesRequest {
1201 pub fn new() -> Self {
1202 std::default::Default::default()
1203 }
1204
1205 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
1207 mut self,
1208 v: T,
1209 ) -> Self {
1210 self.document = v.into();
1211 self
1212 }
1213
1214 pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
1216 mut self,
1217 v: T,
1218 ) -> Self {
1219 self.encoding_type = v.into();
1220 self
1221 }
1222}
1223
1224impl wkt::message::Message for AnalyzeEntitiesRequest {
1225 fn typename() -> &'static str {
1226 "type.googleapis.com/google.cloud.language.v2.AnalyzeEntitiesRequest"
1227 }
1228}
1229
1230#[serde_with::serde_as]
1232#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1233#[serde(default, rename_all = "camelCase")]
1234#[non_exhaustive]
1235pub struct AnalyzeEntitiesResponse {
1236 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1238 pub entities: std::vec::Vec<crate::model::Entity>,
1239
1240 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1244 pub language_code: std::string::String,
1245
1246 #[serde(skip_serializing_if = "wkt::internal::is_default")]
1250 pub language_supported: bool,
1251
1252 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1253 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1254}
1255
1256impl AnalyzeEntitiesResponse {
1257 pub fn new() -> Self {
1258 std::default::Default::default()
1259 }
1260
1261 pub fn set_entities<T, V>(mut self, v: T) -> Self
1263 where
1264 T: std::iter::IntoIterator<Item = V>,
1265 V: std::convert::Into<crate::model::Entity>,
1266 {
1267 use std::iter::Iterator;
1268 self.entities = v.into_iter().map(|i| i.into()).collect();
1269 self
1270 }
1271
1272 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1274 self.language_code = v.into();
1275 self
1276 }
1277
1278 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1280 self.language_supported = v.into();
1281 self
1282 }
1283}
1284
1285impl wkt::message::Message for AnalyzeEntitiesResponse {
1286 fn typename() -> &'static str {
1287 "type.googleapis.com/google.cloud.language.v2.AnalyzeEntitiesResponse"
1288 }
1289}
1290
1291#[serde_with::serde_as]
1293#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1294#[serde(default, rename_all = "camelCase")]
1295#[non_exhaustive]
1296pub struct ClassifyTextRequest {
1297 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1299 pub document: std::option::Option<crate::model::Document>,
1300
1301 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1302 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1303}
1304
1305impl ClassifyTextRequest {
1306 pub fn new() -> Self {
1307 std::default::Default::default()
1308 }
1309
1310 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
1312 mut self,
1313 v: T,
1314 ) -> Self {
1315 self.document = v.into();
1316 self
1317 }
1318}
1319
1320impl wkt::message::Message for ClassifyTextRequest {
1321 fn typename() -> &'static str {
1322 "type.googleapis.com/google.cloud.language.v2.ClassifyTextRequest"
1323 }
1324}
1325
1326#[serde_with::serde_as]
1328#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1329#[serde(default, rename_all = "camelCase")]
1330#[non_exhaustive]
1331pub struct ClassifyTextResponse {
1332 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1334 pub categories: std::vec::Vec<crate::model::ClassificationCategory>,
1335
1336 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1340 pub language_code: std::string::String,
1341
1342 #[serde(skip_serializing_if = "wkt::internal::is_default")]
1346 pub language_supported: bool,
1347
1348 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1349 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1350}
1351
1352impl ClassifyTextResponse {
1353 pub fn new() -> Self {
1354 std::default::Default::default()
1355 }
1356
1357 pub fn set_categories<T, V>(mut self, v: T) -> Self
1359 where
1360 T: std::iter::IntoIterator<Item = V>,
1361 V: std::convert::Into<crate::model::ClassificationCategory>,
1362 {
1363 use std::iter::Iterator;
1364 self.categories = v.into_iter().map(|i| i.into()).collect();
1365 self
1366 }
1367
1368 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1370 self.language_code = v.into();
1371 self
1372 }
1373
1374 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1376 self.language_supported = v.into();
1377 self
1378 }
1379}
1380
1381impl wkt::message::Message for ClassifyTextResponse {
1382 fn typename() -> &'static str {
1383 "type.googleapis.com/google.cloud.language.v2.ClassifyTextResponse"
1384 }
1385}
1386
1387#[serde_with::serde_as]
1389#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1390#[serde(default, rename_all = "camelCase")]
1391#[non_exhaustive]
1392pub struct ModerateTextRequest {
1393 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1395 pub document: std::option::Option<crate::model::Document>,
1396
1397 pub model_version: crate::model::moderate_text_request::ModelVersion,
1399
1400 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1401 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1402}
1403
1404impl ModerateTextRequest {
1405 pub fn new() -> Self {
1406 std::default::Default::default()
1407 }
1408
1409 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
1411 mut self,
1412 v: T,
1413 ) -> Self {
1414 self.document = v.into();
1415 self
1416 }
1417
1418 pub fn set_model_version<
1420 T: std::convert::Into<crate::model::moderate_text_request::ModelVersion>,
1421 >(
1422 mut self,
1423 v: T,
1424 ) -> Self {
1425 self.model_version = v.into();
1426 self
1427 }
1428}
1429
1430impl wkt::message::Message for ModerateTextRequest {
1431 fn typename() -> &'static str {
1432 "type.googleapis.com/google.cloud.language.v2.ModerateTextRequest"
1433 }
1434}
1435
1436pub mod moderate_text_request {
1438 #[allow(unused_imports)]
1439 use super::*;
1440
1441 #[derive(Clone, Debug, PartialEq)]
1457 #[non_exhaustive]
1458 pub enum ModelVersion {
1459 Unspecified,
1461 _1,
1465 _2,
1469 UnknownValue(model_version::UnknownValue),
1474 }
1475
1476 #[doc(hidden)]
1477 pub mod model_version {
1478 #[allow(unused_imports)]
1479 use super::*;
1480 #[derive(Clone, Debug, PartialEq)]
1481 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1482 }
1483
1484 impl ModelVersion {
1485 pub fn value(&self) -> std::option::Option<i32> {
1490 match self {
1491 Self::Unspecified => std::option::Option::Some(0),
1492 Self::_1 => std::option::Option::Some(1),
1493 Self::_2 => std::option::Option::Some(2),
1494 Self::UnknownValue(u) => u.0.value(),
1495 }
1496 }
1497
1498 pub fn name(&self) -> std::option::Option<&str> {
1503 match self {
1504 Self::Unspecified => std::option::Option::Some("MODEL_VERSION_UNSPECIFIED"),
1505 Self::_1 => std::option::Option::Some("MODEL_VERSION_1"),
1506 Self::_2 => std::option::Option::Some("MODEL_VERSION_2"),
1507 Self::UnknownValue(u) => u.0.name(),
1508 }
1509 }
1510 }
1511
1512 impl std::default::Default for ModelVersion {
1513 fn default() -> Self {
1514 use std::convert::From;
1515 Self::from(0)
1516 }
1517 }
1518
1519 impl std::fmt::Display for ModelVersion {
1520 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1521 wkt::internal::display_enum(f, self.name(), self.value())
1522 }
1523 }
1524
1525 impl std::convert::From<i32> for ModelVersion {
1526 fn from(value: i32) -> Self {
1527 match value {
1528 0 => Self::Unspecified,
1529 1 => Self::_1,
1530 2 => Self::_2,
1531 _ => Self::UnknownValue(model_version::UnknownValue(
1532 wkt::internal::UnknownEnumValue::Integer(value),
1533 )),
1534 }
1535 }
1536 }
1537
1538 impl std::convert::From<&str> for ModelVersion {
1539 fn from(value: &str) -> Self {
1540 use std::string::ToString;
1541 match value {
1542 "MODEL_VERSION_UNSPECIFIED" => Self::Unspecified,
1543 "MODEL_VERSION_1" => Self::_1,
1544 "MODEL_VERSION_2" => Self::_2,
1545 _ => Self::UnknownValue(model_version::UnknownValue(
1546 wkt::internal::UnknownEnumValue::String(value.to_string()),
1547 )),
1548 }
1549 }
1550 }
1551
1552 impl serde::ser::Serialize for ModelVersion {
1553 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1554 where
1555 S: serde::Serializer,
1556 {
1557 match self {
1558 Self::Unspecified => serializer.serialize_i32(0),
1559 Self::_1 => serializer.serialize_i32(1),
1560 Self::_2 => serializer.serialize_i32(2),
1561 Self::UnknownValue(u) => u.0.serialize(serializer),
1562 }
1563 }
1564 }
1565
1566 impl<'de> serde::de::Deserialize<'de> for ModelVersion {
1567 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1568 where
1569 D: serde::Deserializer<'de>,
1570 {
1571 deserializer.deserialize_any(wkt::internal::EnumVisitor::<ModelVersion>::new(
1572 ".google.cloud.language.v2.ModerateTextRequest.ModelVersion",
1573 ))
1574 }
1575 }
1576}
1577
1578#[serde_with::serde_as]
1580#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1581#[serde(default, rename_all = "camelCase")]
1582#[non_exhaustive]
1583pub struct ModerateTextResponse {
1584 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1586 pub moderation_categories: std::vec::Vec<crate::model::ClassificationCategory>,
1587
1588 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1592 pub language_code: std::string::String,
1593
1594 #[serde(skip_serializing_if = "wkt::internal::is_default")]
1598 pub language_supported: bool,
1599
1600 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1601 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1602}
1603
1604impl ModerateTextResponse {
1605 pub fn new() -> Self {
1606 std::default::Default::default()
1607 }
1608
1609 pub fn set_moderation_categories<T, V>(mut self, v: T) -> Self
1611 where
1612 T: std::iter::IntoIterator<Item = V>,
1613 V: std::convert::Into<crate::model::ClassificationCategory>,
1614 {
1615 use std::iter::Iterator;
1616 self.moderation_categories = v.into_iter().map(|i| i.into()).collect();
1617 self
1618 }
1619
1620 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1622 self.language_code = v.into();
1623 self
1624 }
1625
1626 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1628 self.language_supported = v.into();
1629 self
1630 }
1631}
1632
1633impl wkt::message::Message for ModerateTextResponse {
1634 fn typename() -> &'static str {
1635 "type.googleapis.com/google.cloud.language.v2.ModerateTextResponse"
1636 }
1637}
1638
1639#[serde_with::serde_as]
1642#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1643#[serde(default, rename_all = "camelCase")]
1644#[non_exhaustive]
1645pub struct AnnotateTextRequest {
1646 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1648 pub document: std::option::Option<crate::model::Document>,
1649
1650 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1652 pub features: std::option::Option<crate::model::annotate_text_request::Features>,
1653
1654 pub encoding_type: crate::model::EncodingType,
1656
1657 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1658 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1659}
1660
1661impl AnnotateTextRequest {
1662 pub fn new() -> Self {
1663 std::default::Default::default()
1664 }
1665
1666 pub fn set_document<T: std::convert::Into<std::option::Option<crate::model::Document>>>(
1668 mut self,
1669 v: T,
1670 ) -> Self {
1671 self.document = v.into();
1672 self
1673 }
1674
1675 pub fn set_features<
1677 T: std::convert::Into<std::option::Option<crate::model::annotate_text_request::Features>>,
1678 >(
1679 mut self,
1680 v: T,
1681 ) -> Self {
1682 self.features = v.into();
1683 self
1684 }
1685
1686 pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
1688 mut self,
1689 v: T,
1690 ) -> Self {
1691 self.encoding_type = v.into();
1692 self
1693 }
1694}
1695
1696impl wkt::message::Message for AnnotateTextRequest {
1697 fn typename() -> &'static str {
1698 "type.googleapis.com/google.cloud.language.v2.AnnotateTextRequest"
1699 }
1700}
1701
1702pub mod annotate_text_request {
1704 #[allow(unused_imports)]
1705 use super::*;
1706
1707 #[serde_with::serde_as]
1710 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1711 #[serde(default, rename_all = "camelCase")]
1712 #[non_exhaustive]
1713 pub struct Features {
1714 #[serde(skip_serializing_if = "wkt::internal::is_default")]
1716 pub extract_entities: bool,
1717
1718 #[serde(skip_serializing_if = "wkt::internal::is_default")]
1720 pub extract_document_sentiment: bool,
1721
1722 #[serde(skip_serializing_if = "wkt::internal::is_default")]
1724 pub classify_text: bool,
1725
1726 #[serde(skip_serializing_if = "wkt::internal::is_default")]
1728 pub moderate_text: bool,
1729
1730 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1731 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1732 }
1733
1734 impl Features {
1735 pub fn new() -> Self {
1736 std::default::Default::default()
1737 }
1738
1739 pub fn set_extract_entities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1741 self.extract_entities = v.into();
1742 self
1743 }
1744
1745 pub fn set_extract_document_sentiment<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1747 self.extract_document_sentiment = v.into();
1748 self
1749 }
1750
1751 pub fn set_classify_text<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1753 self.classify_text = v.into();
1754 self
1755 }
1756
1757 pub fn set_moderate_text<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1759 self.moderate_text = v.into();
1760 self
1761 }
1762 }
1763
1764 impl wkt::message::Message for Features {
1765 fn typename() -> &'static str {
1766 "type.googleapis.com/google.cloud.language.v2.AnnotateTextRequest.Features"
1767 }
1768 }
1769}
1770
1771#[serde_with::serde_as]
1773#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1774#[serde(default, rename_all = "camelCase")]
1775#[non_exhaustive]
1776pub struct AnnotateTextResponse {
1777 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1782 pub sentences: std::vec::Vec<crate::model::Sentence>,
1783
1784 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1792 pub entities: std::vec::Vec<crate::model::Entity>,
1793
1794 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1799 pub document_sentiment: std::option::Option<crate::model::Sentiment>,
1800
1801 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1805 pub language_code: std::string::String,
1806
1807 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1809 pub categories: std::vec::Vec<crate::model::ClassificationCategory>,
1810
1811 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1813 pub moderation_categories: std::vec::Vec<crate::model::ClassificationCategory>,
1814
1815 #[serde(skip_serializing_if = "wkt::internal::is_default")]
1819 pub language_supported: bool,
1820
1821 #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1822 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1823}
1824
1825impl AnnotateTextResponse {
1826 pub fn new() -> Self {
1827 std::default::Default::default()
1828 }
1829
1830 pub fn set_sentences<T, V>(mut self, v: T) -> Self
1832 where
1833 T: std::iter::IntoIterator<Item = V>,
1834 V: std::convert::Into<crate::model::Sentence>,
1835 {
1836 use std::iter::Iterator;
1837 self.sentences = v.into_iter().map(|i| i.into()).collect();
1838 self
1839 }
1840
1841 pub fn set_entities<T, V>(mut self, v: T) -> Self
1843 where
1844 T: std::iter::IntoIterator<Item = V>,
1845 V: std::convert::Into<crate::model::Entity>,
1846 {
1847 use std::iter::Iterator;
1848 self.entities = v.into_iter().map(|i| i.into()).collect();
1849 self
1850 }
1851
1852 pub fn set_document_sentiment<
1854 T: std::convert::Into<std::option::Option<crate::model::Sentiment>>,
1855 >(
1856 mut self,
1857 v: T,
1858 ) -> Self {
1859 self.document_sentiment = v.into();
1860 self
1861 }
1862
1863 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1865 self.language_code = v.into();
1866 self
1867 }
1868
1869 pub fn set_categories<T, V>(mut self, v: T) -> Self
1871 where
1872 T: std::iter::IntoIterator<Item = V>,
1873 V: std::convert::Into<crate::model::ClassificationCategory>,
1874 {
1875 use std::iter::Iterator;
1876 self.categories = v.into_iter().map(|i| i.into()).collect();
1877 self
1878 }
1879
1880 pub fn set_moderation_categories<T, V>(mut self, v: T) -> Self
1882 where
1883 T: std::iter::IntoIterator<Item = V>,
1884 V: std::convert::Into<crate::model::ClassificationCategory>,
1885 {
1886 use std::iter::Iterator;
1887 self.moderation_categories = v.into_iter().map(|i| i.into()).collect();
1888 self
1889 }
1890
1891 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1893 self.language_supported = v.into();
1894 self
1895 }
1896}
1897
1898impl wkt::message::Message for AnnotateTextResponse {
1899 fn typename() -> &'static str {
1900 "type.googleapis.com/google.cloud.language.v2.AnnotateTextResponse"
1901 }
1902}
1903
1904#[derive(Clone, Debug, PartialEq)]
1924#[non_exhaustive]
1925pub enum EncodingType {
1926 None,
1929 Utf8,
1933 Utf16,
1937 Utf32,
1941 UnknownValue(encoding_type::UnknownValue),
1946}
1947
1948#[doc(hidden)]
1949pub mod encoding_type {
1950 #[allow(unused_imports)]
1951 use super::*;
1952 #[derive(Clone, Debug, PartialEq)]
1953 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1954}
1955
1956impl EncodingType {
1957 pub fn value(&self) -> std::option::Option<i32> {
1962 match self {
1963 Self::None => std::option::Option::Some(0),
1964 Self::Utf8 => std::option::Option::Some(1),
1965 Self::Utf16 => std::option::Option::Some(2),
1966 Self::Utf32 => std::option::Option::Some(3),
1967 Self::UnknownValue(u) => u.0.value(),
1968 }
1969 }
1970
1971 pub fn name(&self) -> std::option::Option<&str> {
1976 match self {
1977 Self::None => std::option::Option::Some("NONE"),
1978 Self::Utf8 => std::option::Option::Some("UTF8"),
1979 Self::Utf16 => std::option::Option::Some("UTF16"),
1980 Self::Utf32 => std::option::Option::Some("UTF32"),
1981 Self::UnknownValue(u) => u.0.name(),
1982 }
1983 }
1984}
1985
1986impl std::default::Default for EncodingType {
1987 fn default() -> Self {
1988 use std::convert::From;
1989 Self::from(0)
1990 }
1991}
1992
1993impl std::fmt::Display for EncodingType {
1994 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1995 wkt::internal::display_enum(f, self.name(), self.value())
1996 }
1997}
1998
1999impl std::convert::From<i32> for EncodingType {
2000 fn from(value: i32) -> Self {
2001 match value {
2002 0 => Self::None,
2003 1 => Self::Utf8,
2004 2 => Self::Utf16,
2005 3 => Self::Utf32,
2006 _ => Self::UnknownValue(encoding_type::UnknownValue(
2007 wkt::internal::UnknownEnumValue::Integer(value),
2008 )),
2009 }
2010 }
2011}
2012
2013impl std::convert::From<&str> for EncodingType {
2014 fn from(value: &str) -> Self {
2015 use std::string::ToString;
2016 match value {
2017 "NONE" => Self::None,
2018 "UTF8" => Self::Utf8,
2019 "UTF16" => Self::Utf16,
2020 "UTF32" => Self::Utf32,
2021 _ => Self::UnknownValue(encoding_type::UnknownValue(
2022 wkt::internal::UnknownEnumValue::String(value.to_string()),
2023 )),
2024 }
2025 }
2026}
2027
2028impl serde::ser::Serialize for EncodingType {
2029 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2030 where
2031 S: serde::Serializer,
2032 {
2033 match self {
2034 Self::None => serializer.serialize_i32(0),
2035 Self::Utf8 => serializer.serialize_i32(1),
2036 Self::Utf16 => serializer.serialize_i32(2),
2037 Self::Utf32 => serializer.serialize_i32(3),
2038 Self::UnknownValue(u) => u.0.serialize(serializer),
2039 }
2040 }
2041}
2042
2043impl<'de> serde::de::Deserialize<'de> for EncodingType {
2044 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2045 where
2046 D: serde::Deserializer<'de>,
2047 {
2048 deserializer.deserialize_any(wkt::internal::EnumVisitor::<EncodingType>::new(
2049 ".google.cloud.language.v2.EncodingType",
2050 ))
2051 }
2052}