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
33mod debug;
34mod deserialize;
35mod serialize;
36
37#[derive(Clone, Default, PartialEq)]
39#[non_exhaustive]
40pub struct Document {
41 pub r#type: crate::model::document::Type,
44
45 pub language_code: std::string::String,
54
55 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 pub fn set_type<T: std::convert::Into<crate::model::document::Type>>(mut self, v: T) -> Self {
69 self.r#type = v.into();
70 self
71 }
72
73 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
75 self.language_code = v.into();
76 self
77 }
78
79 pub fn set_source<
84 T: std::convert::Into<std::option::Option<crate::model::document::Source>>,
85 >(
86 mut self,
87 v: T,
88 ) -> Self {
89 self.source = v.into();
90 self
91 }
92
93 pub fn content(&self) -> std::option::Option<&std::string::String> {
97 #[allow(unreachable_patterns)]
98 self.source.as_ref().and_then(|v| match v {
99 crate::model::document::Source::Content(v) => std::option::Option::Some(v),
100 _ => std::option::Option::None,
101 })
102 }
103
104 pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
110 self.source = std::option::Option::Some(crate::model::document::Source::Content(v.into()));
111 self
112 }
113
114 pub fn gcs_content_uri(&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::GcsContentUri(v) => std::option::Option::Some(v),
121 _ => std::option::Option::None,
122 })
123 }
124
125 pub fn set_gcs_content_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
131 self.source =
132 std::option::Option::Some(crate::model::document::Source::GcsContentUri(v.into()));
133 self
134 }
135}
136
137impl wkt::message::Message for Document {
138 fn typename() -> &'static str {
139 "type.googleapis.com/google.cloud.language.v2.Document"
140 }
141}
142
143pub mod document {
145 #[allow(unused_imports)]
146 use super::*;
147
148 #[derive(Clone, Debug, PartialEq)]
164 #[non_exhaustive]
165 pub enum Type {
166 Unspecified,
168 PlainText,
170 Html,
172 UnknownValue(r#type::UnknownValue),
177 }
178
179 #[doc(hidden)]
180 pub mod r#type {
181 #[allow(unused_imports)]
182 use super::*;
183 #[derive(Clone, Debug, PartialEq)]
184 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
185 }
186
187 impl Type {
188 pub fn value(&self) -> std::option::Option<i32> {
193 match self {
194 Self::Unspecified => std::option::Option::Some(0),
195 Self::PlainText => std::option::Option::Some(1),
196 Self::Html => std::option::Option::Some(2),
197 Self::UnknownValue(u) => u.0.value(),
198 }
199 }
200
201 pub fn name(&self) -> std::option::Option<&str> {
206 match self {
207 Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
208 Self::PlainText => std::option::Option::Some("PLAIN_TEXT"),
209 Self::Html => std::option::Option::Some("HTML"),
210 Self::UnknownValue(u) => u.0.name(),
211 }
212 }
213 }
214
215 impl std::default::Default for Type {
216 fn default() -> Self {
217 use std::convert::From;
218 Self::from(0)
219 }
220 }
221
222 impl std::fmt::Display for Type {
223 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
224 wkt::internal::display_enum(f, self.name(), self.value())
225 }
226 }
227
228 impl std::convert::From<i32> for Type {
229 fn from(value: i32) -> Self {
230 match value {
231 0 => Self::Unspecified,
232 1 => Self::PlainText,
233 2 => Self::Html,
234 _ => Self::UnknownValue(r#type::UnknownValue(
235 wkt::internal::UnknownEnumValue::Integer(value),
236 )),
237 }
238 }
239 }
240
241 impl std::convert::From<&str> for Type {
242 fn from(value: &str) -> Self {
243 use std::string::ToString;
244 match value {
245 "TYPE_UNSPECIFIED" => Self::Unspecified,
246 "PLAIN_TEXT" => Self::PlainText,
247 "HTML" => Self::Html,
248 _ => Self::UnknownValue(r#type::UnknownValue(
249 wkt::internal::UnknownEnumValue::String(value.to_string()),
250 )),
251 }
252 }
253 }
254
255 impl serde::ser::Serialize for Type {
256 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
257 where
258 S: serde::Serializer,
259 {
260 match self {
261 Self::Unspecified => serializer.serialize_i32(0),
262 Self::PlainText => serializer.serialize_i32(1),
263 Self::Html => serializer.serialize_i32(2),
264 Self::UnknownValue(u) => u.0.serialize(serializer),
265 }
266 }
267 }
268
269 impl<'de> serde::de::Deserialize<'de> for Type {
270 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
271 where
272 D: serde::Deserializer<'de>,
273 {
274 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
275 ".google.cloud.language.v2.Document.Type",
276 ))
277 }
278 }
279
280 #[derive(Clone, Debug, PartialEq)]
283 #[non_exhaustive]
284 pub enum Source {
285 Content(std::string::String),
288 GcsContentUri(std::string::String),
293 }
294}
295
296#[derive(Clone, Default, PartialEq)]
298#[non_exhaustive]
299pub struct Sentence {
300 pub text: std::option::Option<crate::model::TextSpan>,
302
303 pub sentiment: std::option::Option<crate::model::Sentiment>,
309
310 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
311}
312
313impl Sentence {
314 pub fn new() -> Self {
315 std::default::Default::default()
316 }
317
318 pub fn set_text<T>(mut self, v: T) -> Self
320 where
321 T: std::convert::Into<crate::model::TextSpan>,
322 {
323 self.text = std::option::Option::Some(v.into());
324 self
325 }
326
327 pub fn set_or_clear_text<T>(mut self, v: std::option::Option<T>) -> Self
329 where
330 T: std::convert::Into<crate::model::TextSpan>,
331 {
332 self.text = v.map(|x| x.into());
333 self
334 }
335
336 pub fn set_sentiment<T>(mut self, v: T) -> Self
338 where
339 T: std::convert::Into<crate::model::Sentiment>,
340 {
341 self.sentiment = std::option::Option::Some(v.into());
342 self
343 }
344
345 pub fn set_or_clear_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
347 where
348 T: std::convert::Into<crate::model::Sentiment>,
349 {
350 self.sentiment = v.map(|x| x.into());
351 self
352 }
353}
354
355impl wkt::message::Message for Sentence {
356 fn typename() -> &'static str {
357 "type.googleapis.com/google.cloud.language.v2.Sentence"
358 }
359}
360
361#[derive(Clone, Default, PartialEq)]
365#[non_exhaustive]
366pub struct Entity {
367 pub name: std::string::String,
369
370 pub r#type: crate::model::entity::Type,
372
373 pub metadata: std::collections::HashMap<std::string::String, std::string::String>,
378
379 pub mentions: std::vec::Vec<crate::model::EntityMention>,
382
383 pub sentiment: std::option::Option<crate::model::Sentiment>,
388
389 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
390}
391
392impl Entity {
393 pub fn new() -> Self {
394 std::default::Default::default()
395 }
396
397 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
399 self.name = v.into();
400 self
401 }
402
403 pub fn set_type<T: std::convert::Into<crate::model::entity::Type>>(mut self, v: T) -> Self {
405 self.r#type = v.into();
406 self
407 }
408
409 pub fn set_metadata<T, K, V>(mut self, v: T) -> Self
411 where
412 T: std::iter::IntoIterator<Item = (K, V)>,
413 K: std::convert::Into<std::string::String>,
414 V: std::convert::Into<std::string::String>,
415 {
416 use std::iter::Iterator;
417 self.metadata = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
418 self
419 }
420
421 pub fn set_mentions<T, V>(mut self, v: T) -> Self
423 where
424 T: std::iter::IntoIterator<Item = V>,
425 V: std::convert::Into<crate::model::EntityMention>,
426 {
427 use std::iter::Iterator;
428 self.mentions = v.into_iter().map(|i| i.into()).collect();
429 self
430 }
431
432 pub fn set_sentiment<T>(mut self, v: T) -> Self
434 where
435 T: std::convert::Into<crate::model::Sentiment>,
436 {
437 self.sentiment = std::option::Option::Some(v.into());
438 self
439 }
440
441 pub fn set_or_clear_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
443 where
444 T: std::convert::Into<crate::model::Sentiment>,
445 {
446 self.sentiment = v.map(|x| x.into());
447 self
448 }
449}
450
451impl wkt::message::Message for Entity {
452 fn typename() -> &'static str {
453 "type.googleapis.com/google.cloud.language.v2.Entity"
454 }
455}
456
457pub mod entity {
459 #[allow(unused_imports)]
460 use super::*;
461
462 #[derive(Clone, Debug, PartialEq)]
480 #[non_exhaustive]
481 pub enum Type {
482 Unknown,
484 Person,
486 Location,
488 Organization,
490 Event,
492 WorkOfArt,
494 ConsumerGood,
496 Other,
498 PhoneNumber,
510 Address,
526 Date,
534 Number,
538 Price,
542 UnknownValue(r#type::UnknownValue),
547 }
548
549 #[doc(hidden)]
550 pub mod r#type {
551 #[allow(unused_imports)]
552 use super::*;
553 #[derive(Clone, Debug, PartialEq)]
554 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
555 }
556
557 impl Type {
558 pub fn value(&self) -> std::option::Option<i32> {
563 match self {
564 Self::Unknown => std::option::Option::Some(0),
565 Self::Person => std::option::Option::Some(1),
566 Self::Location => std::option::Option::Some(2),
567 Self::Organization => std::option::Option::Some(3),
568 Self::Event => std::option::Option::Some(4),
569 Self::WorkOfArt => std::option::Option::Some(5),
570 Self::ConsumerGood => std::option::Option::Some(6),
571 Self::Other => std::option::Option::Some(7),
572 Self::PhoneNumber => std::option::Option::Some(9),
573 Self::Address => std::option::Option::Some(10),
574 Self::Date => std::option::Option::Some(11),
575 Self::Number => std::option::Option::Some(12),
576 Self::Price => std::option::Option::Some(13),
577 Self::UnknownValue(u) => u.0.value(),
578 }
579 }
580
581 pub fn name(&self) -> std::option::Option<&str> {
586 match self {
587 Self::Unknown => std::option::Option::Some("UNKNOWN"),
588 Self::Person => std::option::Option::Some("PERSON"),
589 Self::Location => std::option::Option::Some("LOCATION"),
590 Self::Organization => std::option::Option::Some("ORGANIZATION"),
591 Self::Event => std::option::Option::Some("EVENT"),
592 Self::WorkOfArt => std::option::Option::Some("WORK_OF_ART"),
593 Self::ConsumerGood => std::option::Option::Some("CONSUMER_GOOD"),
594 Self::Other => std::option::Option::Some("OTHER"),
595 Self::PhoneNumber => std::option::Option::Some("PHONE_NUMBER"),
596 Self::Address => std::option::Option::Some("ADDRESS"),
597 Self::Date => std::option::Option::Some("DATE"),
598 Self::Number => std::option::Option::Some("NUMBER"),
599 Self::Price => std::option::Option::Some("PRICE"),
600 Self::UnknownValue(u) => u.0.name(),
601 }
602 }
603 }
604
605 impl std::default::Default for Type {
606 fn default() -> Self {
607 use std::convert::From;
608 Self::from(0)
609 }
610 }
611
612 impl std::fmt::Display for Type {
613 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
614 wkt::internal::display_enum(f, self.name(), self.value())
615 }
616 }
617
618 impl std::convert::From<i32> for Type {
619 fn from(value: i32) -> Self {
620 match value {
621 0 => Self::Unknown,
622 1 => Self::Person,
623 2 => Self::Location,
624 3 => Self::Organization,
625 4 => Self::Event,
626 5 => Self::WorkOfArt,
627 6 => Self::ConsumerGood,
628 7 => Self::Other,
629 9 => Self::PhoneNumber,
630 10 => Self::Address,
631 11 => Self::Date,
632 12 => Self::Number,
633 13 => Self::Price,
634 _ => Self::UnknownValue(r#type::UnknownValue(
635 wkt::internal::UnknownEnumValue::Integer(value),
636 )),
637 }
638 }
639 }
640
641 impl std::convert::From<&str> for Type {
642 fn from(value: &str) -> Self {
643 use std::string::ToString;
644 match value {
645 "UNKNOWN" => Self::Unknown,
646 "PERSON" => Self::Person,
647 "LOCATION" => Self::Location,
648 "ORGANIZATION" => Self::Organization,
649 "EVENT" => Self::Event,
650 "WORK_OF_ART" => Self::WorkOfArt,
651 "CONSUMER_GOOD" => Self::ConsumerGood,
652 "OTHER" => Self::Other,
653 "PHONE_NUMBER" => Self::PhoneNumber,
654 "ADDRESS" => Self::Address,
655 "DATE" => Self::Date,
656 "NUMBER" => Self::Number,
657 "PRICE" => Self::Price,
658 _ => Self::UnknownValue(r#type::UnknownValue(
659 wkt::internal::UnknownEnumValue::String(value.to_string()),
660 )),
661 }
662 }
663 }
664
665 impl serde::ser::Serialize for Type {
666 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
667 where
668 S: serde::Serializer,
669 {
670 match self {
671 Self::Unknown => serializer.serialize_i32(0),
672 Self::Person => serializer.serialize_i32(1),
673 Self::Location => serializer.serialize_i32(2),
674 Self::Organization => serializer.serialize_i32(3),
675 Self::Event => serializer.serialize_i32(4),
676 Self::WorkOfArt => serializer.serialize_i32(5),
677 Self::ConsumerGood => serializer.serialize_i32(6),
678 Self::Other => serializer.serialize_i32(7),
679 Self::PhoneNumber => serializer.serialize_i32(9),
680 Self::Address => serializer.serialize_i32(10),
681 Self::Date => serializer.serialize_i32(11),
682 Self::Number => serializer.serialize_i32(12),
683 Self::Price => serializer.serialize_i32(13),
684 Self::UnknownValue(u) => u.0.serialize(serializer),
685 }
686 }
687 }
688
689 impl<'de> serde::de::Deserialize<'de> for Type {
690 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
691 where
692 D: serde::Deserializer<'de>,
693 {
694 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
695 ".google.cloud.language.v2.Entity.Type",
696 ))
697 }
698 }
699}
700
701#[derive(Clone, Default, PartialEq)]
704#[non_exhaustive]
705pub struct Sentiment {
706 pub magnitude: f32,
710
711 pub score: f32,
714
715 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
716}
717
718impl Sentiment {
719 pub fn new() -> Self {
720 std::default::Default::default()
721 }
722
723 pub fn set_magnitude<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
725 self.magnitude = v.into();
726 self
727 }
728
729 pub fn set_score<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
731 self.score = v.into();
732 self
733 }
734}
735
736impl wkt::message::Message for Sentiment {
737 fn typename() -> &'static str {
738 "type.googleapis.com/google.cloud.language.v2.Sentiment"
739 }
740}
741
742#[derive(Clone, Default, PartialEq)]
745#[non_exhaustive]
746pub struct EntityMention {
747 pub text: std::option::Option<crate::model::TextSpan>,
749
750 pub r#type: crate::model::entity_mention::Type,
752
753 pub sentiment: std::option::Option<crate::model::Sentiment>,
758
759 pub probability: f32,
764
765 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
766}
767
768impl EntityMention {
769 pub fn new() -> Self {
770 std::default::Default::default()
771 }
772
773 pub fn set_text<T>(mut self, v: T) -> Self
775 where
776 T: std::convert::Into<crate::model::TextSpan>,
777 {
778 self.text = std::option::Option::Some(v.into());
779 self
780 }
781
782 pub fn set_or_clear_text<T>(mut self, v: std::option::Option<T>) -> Self
784 where
785 T: std::convert::Into<crate::model::TextSpan>,
786 {
787 self.text = v.map(|x| x.into());
788 self
789 }
790
791 pub fn set_type<T: std::convert::Into<crate::model::entity_mention::Type>>(
793 mut self,
794 v: T,
795 ) -> Self {
796 self.r#type = v.into();
797 self
798 }
799
800 pub fn set_sentiment<T>(mut self, v: T) -> Self
802 where
803 T: std::convert::Into<crate::model::Sentiment>,
804 {
805 self.sentiment = std::option::Option::Some(v.into());
806 self
807 }
808
809 pub fn set_or_clear_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
811 where
812 T: std::convert::Into<crate::model::Sentiment>,
813 {
814 self.sentiment = v.map(|x| x.into());
815 self
816 }
817
818 pub fn set_probability<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
820 self.probability = v.into();
821 self
822 }
823}
824
825impl wkt::message::Message for EntityMention {
826 fn typename() -> &'static str {
827 "type.googleapis.com/google.cloud.language.v2.EntityMention"
828 }
829}
830
831pub mod entity_mention {
833 #[allow(unused_imports)]
834 use super::*;
835
836 #[derive(Clone, Debug, PartialEq)]
852 #[non_exhaustive]
853 pub enum Type {
854 Unknown,
856 Proper,
858 Common,
860 UnknownValue(r#type::UnknownValue),
865 }
866
867 #[doc(hidden)]
868 pub mod r#type {
869 #[allow(unused_imports)]
870 use super::*;
871 #[derive(Clone, Debug, PartialEq)]
872 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
873 }
874
875 impl Type {
876 pub fn value(&self) -> std::option::Option<i32> {
881 match self {
882 Self::Unknown => std::option::Option::Some(0),
883 Self::Proper => std::option::Option::Some(1),
884 Self::Common => std::option::Option::Some(2),
885 Self::UnknownValue(u) => u.0.value(),
886 }
887 }
888
889 pub fn name(&self) -> std::option::Option<&str> {
894 match self {
895 Self::Unknown => std::option::Option::Some("TYPE_UNKNOWN"),
896 Self::Proper => std::option::Option::Some("PROPER"),
897 Self::Common => std::option::Option::Some("COMMON"),
898 Self::UnknownValue(u) => u.0.name(),
899 }
900 }
901 }
902
903 impl std::default::Default for Type {
904 fn default() -> Self {
905 use std::convert::From;
906 Self::from(0)
907 }
908 }
909
910 impl std::fmt::Display for Type {
911 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
912 wkt::internal::display_enum(f, self.name(), self.value())
913 }
914 }
915
916 impl std::convert::From<i32> for Type {
917 fn from(value: i32) -> Self {
918 match value {
919 0 => Self::Unknown,
920 1 => Self::Proper,
921 2 => Self::Common,
922 _ => Self::UnknownValue(r#type::UnknownValue(
923 wkt::internal::UnknownEnumValue::Integer(value),
924 )),
925 }
926 }
927 }
928
929 impl std::convert::From<&str> for Type {
930 fn from(value: &str) -> Self {
931 use std::string::ToString;
932 match value {
933 "TYPE_UNKNOWN" => Self::Unknown,
934 "PROPER" => Self::Proper,
935 "COMMON" => Self::Common,
936 _ => Self::UnknownValue(r#type::UnknownValue(
937 wkt::internal::UnknownEnumValue::String(value.to_string()),
938 )),
939 }
940 }
941 }
942
943 impl serde::ser::Serialize for Type {
944 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
945 where
946 S: serde::Serializer,
947 {
948 match self {
949 Self::Unknown => serializer.serialize_i32(0),
950 Self::Proper => serializer.serialize_i32(1),
951 Self::Common => serializer.serialize_i32(2),
952 Self::UnknownValue(u) => u.0.serialize(serializer),
953 }
954 }
955 }
956
957 impl<'de> serde::de::Deserialize<'de> for Type {
958 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
959 where
960 D: serde::Deserializer<'de>,
961 {
962 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
963 ".google.cloud.language.v2.EntityMention.Type",
964 ))
965 }
966 }
967}
968
969#[derive(Clone, Default, PartialEq)]
971#[non_exhaustive]
972pub struct TextSpan {
973 pub content: std::string::String,
975
976 pub begin_offset: i32,
983
984 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
985}
986
987impl TextSpan {
988 pub fn new() -> Self {
989 std::default::Default::default()
990 }
991
992 pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
994 self.content = v.into();
995 self
996 }
997
998 pub fn set_begin_offset<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1000 self.begin_offset = v.into();
1001 self
1002 }
1003}
1004
1005impl wkt::message::Message for TextSpan {
1006 fn typename() -> &'static str {
1007 "type.googleapis.com/google.cloud.language.v2.TextSpan"
1008 }
1009}
1010
1011#[derive(Clone, Default, PartialEq)]
1013#[non_exhaustive]
1014pub struct ClassificationCategory {
1015 pub name: std::string::String,
1017
1018 pub confidence: f32,
1021
1022 pub severity: f32,
1026
1027 pub(crate) _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#[derive(Clone, Default, PartialEq)]
1062#[non_exhaustive]
1063pub struct AnalyzeSentimentRequest {
1064 pub document: std::option::Option<crate::model::Document>,
1066
1067 pub encoding_type: crate::model::EncodingType,
1069
1070 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1071}
1072
1073impl AnalyzeSentimentRequest {
1074 pub fn new() -> Self {
1075 std::default::Default::default()
1076 }
1077
1078 pub fn set_document<T>(mut self, v: T) -> Self
1080 where
1081 T: std::convert::Into<crate::model::Document>,
1082 {
1083 self.document = std::option::Option::Some(v.into());
1084 self
1085 }
1086
1087 pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1089 where
1090 T: std::convert::Into<crate::model::Document>,
1091 {
1092 self.document = v.map(|x| x.into());
1093 self
1094 }
1095
1096 pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
1098 mut self,
1099 v: T,
1100 ) -> Self {
1101 self.encoding_type = v.into();
1102 self
1103 }
1104}
1105
1106impl wkt::message::Message for AnalyzeSentimentRequest {
1107 fn typename() -> &'static str {
1108 "type.googleapis.com/google.cloud.language.v2.AnalyzeSentimentRequest"
1109 }
1110}
1111
1112#[derive(Clone, Default, PartialEq)]
1114#[non_exhaustive]
1115pub struct AnalyzeSentimentResponse {
1116 pub document_sentiment: std::option::Option<crate::model::Sentiment>,
1118
1119 pub language_code: std::string::String,
1123
1124 pub sentences: std::vec::Vec<crate::model::Sentence>,
1126
1127 pub language_supported: bool,
1131
1132 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1133}
1134
1135impl AnalyzeSentimentResponse {
1136 pub fn new() -> Self {
1137 std::default::Default::default()
1138 }
1139
1140 pub fn set_document_sentiment<T>(mut self, v: T) -> Self
1142 where
1143 T: std::convert::Into<crate::model::Sentiment>,
1144 {
1145 self.document_sentiment = std::option::Option::Some(v.into());
1146 self
1147 }
1148
1149 pub fn set_or_clear_document_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
1151 where
1152 T: std::convert::Into<crate::model::Sentiment>,
1153 {
1154 self.document_sentiment = v.map(|x| x.into());
1155 self
1156 }
1157
1158 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1160 self.language_code = v.into();
1161 self
1162 }
1163
1164 pub fn set_sentences<T, V>(mut self, v: T) -> Self
1166 where
1167 T: std::iter::IntoIterator<Item = V>,
1168 V: std::convert::Into<crate::model::Sentence>,
1169 {
1170 use std::iter::Iterator;
1171 self.sentences = v.into_iter().map(|i| i.into()).collect();
1172 self
1173 }
1174
1175 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1177 self.language_supported = v.into();
1178 self
1179 }
1180}
1181
1182impl wkt::message::Message for AnalyzeSentimentResponse {
1183 fn typename() -> &'static str {
1184 "type.googleapis.com/google.cloud.language.v2.AnalyzeSentimentResponse"
1185 }
1186}
1187
1188#[derive(Clone, Default, PartialEq)]
1190#[non_exhaustive]
1191pub struct AnalyzeEntitiesRequest {
1192 pub document: std::option::Option<crate::model::Document>,
1194
1195 pub encoding_type: crate::model::EncodingType,
1197
1198 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1199}
1200
1201impl AnalyzeEntitiesRequest {
1202 pub fn new() -> Self {
1203 std::default::Default::default()
1204 }
1205
1206 pub fn set_document<T>(mut self, v: T) -> Self
1208 where
1209 T: std::convert::Into<crate::model::Document>,
1210 {
1211 self.document = std::option::Option::Some(v.into());
1212 self
1213 }
1214
1215 pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1217 where
1218 T: std::convert::Into<crate::model::Document>,
1219 {
1220 self.document = v.map(|x| x.into());
1221 self
1222 }
1223
1224 pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
1226 mut self,
1227 v: T,
1228 ) -> Self {
1229 self.encoding_type = v.into();
1230 self
1231 }
1232}
1233
1234impl wkt::message::Message for AnalyzeEntitiesRequest {
1235 fn typename() -> &'static str {
1236 "type.googleapis.com/google.cloud.language.v2.AnalyzeEntitiesRequest"
1237 }
1238}
1239
1240#[derive(Clone, Default, PartialEq)]
1242#[non_exhaustive]
1243pub struct AnalyzeEntitiesResponse {
1244 pub entities: std::vec::Vec<crate::model::Entity>,
1246
1247 pub language_code: std::string::String,
1251
1252 pub language_supported: bool,
1256
1257 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1258}
1259
1260impl AnalyzeEntitiesResponse {
1261 pub fn new() -> Self {
1262 std::default::Default::default()
1263 }
1264
1265 pub fn set_entities<T, V>(mut self, v: T) -> Self
1267 where
1268 T: std::iter::IntoIterator<Item = V>,
1269 V: std::convert::Into<crate::model::Entity>,
1270 {
1271 use std::iter::Iterator;
1272 self.entities = v.into_iter().map(|i| i.into()).collect();
1273 self
1274 }
1275
1276 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1278 self.language_code = v.into();
1279 self
1280 }
1281
1282 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1284 self.language_supported = v.into();
1285 self
1286 }
1287}
1288
1289impl wkt::message::Message for AnalyzeEntitiesResponse {
1290 fn typename() -> &'static str {
1291 "type.googleapis.com/google.cloud.language.v2.AnalyzeEntitiesResponse"
1292 }
1293}
1294
1295#[derive(Clone, Default, PartialEq)]
1297#[non_exhaustive]
1298pub struct ClassifyTextRequest {
1299 pub document: std::option::Option<crate::model::Document>,
1301
1302 pub(crate) _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>(mut self, v: T) -> Self
1312 where
1313 T: std::convert::Into<crate::model::Document>,
1314 {
1315 self.document = std::option::Option::Some(v.into());
1316 self
1317 }
1318
1319 pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1321 where
1322 T: std::convert::Into<crate::model::Document>,
1323 {
1324 self.document = v.map(|x| x.into());
1325 self
1326 }
1327}
1328
1329impl wkt::message::Message for ClassifyTextRequest {
1330 fn typename() -> &'static str {
1331 "type.googleapis.com/google.cloud.language.v2.ClassifyTextRequest"
1332 }
1333}
1334
1335#[derive(Clone, Default, PartialEq)]
1337#[non_exhaustive]
1338pub struct ClassifyTextResponse {
1339 pub categories: std::vec::Vec<crate::model::ClassificationCategory>,
1341
1342 pub language_code: std::string::String,
1346
1347 pub language_supported: bool,
1351
1352 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1353}
1354
1355impl ClassifyTextResponse {
1356 pub fn new() -> Self {
1357 std::default::Default::default()
1358 }
1359
1360 pub fn set_categories<T, V>(mut self, v: T) -> Self
1362 where
1363 T: std::iter::IntoIterator<Item = V>,
1364 V: std::convert::Into<crate::model::ClassificationCategory>,
1365 {
1366 use std::iter::Iterator;
1367 self.categories = v.into_iter().map(|i| i.into()).collect();
1368 self
1369 }
1370
1371 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1373 self.language_code = v.into();
1374 self
1375 }
1376
1377 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1379 self.language_supported = v.into();
1380 self
1381 }
1382}
1383
1384impl wkt::message::Message for ClassifyTextResponse {
1385 fn typename() -> &'static str {
1386 "type.googleapis.com/google.cloud.language.v2.ClassifyTextResponse"
1387 }
1388}
1389
1390#[derive(Clone, Default, PartialEq)]
1392#[non_exhaustive]
1393pub struct ModerateTextRequest {
1394 pub document: std::option::Option<crate::model::Document>,
1396
1397 pub model_version: crate::model::moderate_text_request::ModelVersion,
1399
1400 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1401}
1402
1403impl ModerateTextRequest {
1404 pub fn new() -> Self {
1405 std::default::Default::default()
1406 }
1407
1408 pub fn set_document<T>(mut self, v: T) -> Self
1410 where
1411 T: std::convert::Into<crate::model::Document>,
1412 {
1413 self.document = std::option::Option::Some(v.into());
1414 self
1415 }
1416
1417 pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1419 where
1420 T: std::convert::Into<crate::model::Document>,
1421 {
1422 self.document = v.map(|x| x.into());
1423 self
1424 }
1425
1426 pub fn set_model_version<
1428 T: std::convert::Into<crate::model::moderate_text_request::ModelVersion>,
1429 >(
1430 mut self,
1431 v: T,
1432 ) -> Self {
1433 self.model_version = v.into();
1434 self
1435 }
1436}
1437
1438impl wkt::message::Message for ModerateTextRequest {
1439 fn typename() -> &'static str {
1440 "type.googleapis.com/google.cloud.language.v2.ModerateTextRequest"
1441 }
1442}
1443
1444pub mod moderate_text_request {
1446 #[allow(unused_imports)]
1447 use super::*;
1448
1449 #[derive(Clone, Debug, PartialEq)]
1465 #[non_exhaustive]
1466 pub enum ModelVersion {
1467 Unspecified,
1469 ModelVersion1,
1473 ModelVersion2,
1477 UnknownValue(model_version::UnknownValue),
1482 }
1483
1484 #[doc(hidden)]
1485 pub mod model_version {
1486 #[allow(unused_imports)]
1487 use super::*;
1488 #[derive(Clone, Debug, PartialEq)]
1489 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1490 }
1491
1492 impl ModelVersion {
1493 pub fn value(&self) -> std::option::Option<i32> {
1498 match self {
1499 Self::Unspecified => std::option::Option::Some(0),
1500 Self::ModelVersion1 => std::option::Option::Some(1),
1501 Self::ModelVersion2 => std::option::Option::Some(2),
1502 Self::UnknownValue(u) => u.0.value(),
1503 }
1504 }
1505
1506 pub fn name(&self) -> std::option::Option<&str> {
1511 match self {
1512 Self::Unspecified => std::option::Option::Some("MODEL_VERSION_UNSPECIFIED"),
1513 Self::ModelVersion1 => std::option::Option::Some("MODEL_VERSION_1"),
1514 Self::ModelVersion2 => std::option::Option::Some("MODEL_VERSION_2"),
1515 Self::UnknownValue(u) => u.0.name(),
1516 }
1517 }
1518 }
1519
1520 impl std::default::Default for ModelVersion {
1521 fn default() -> Self {
1522 use std::convert::From;
1523 Self::from(0)
1524 }
1525 }
1526
1527 impl std::fmt::Display for ModelVersion {
1528 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1529 wkt::internal::display_enum(f, self.name(), self.value())
1530 }
1531 }
1532
1533 impl std::convert::From<i32> for ModelVersion {
1534 fn from(value: i32) -> Self {
1535 match value {
1536 0 => Self::Unspecified,
1537 1 => Self::ModelVersion1,
1538 2 => Self::ModelVersion2,
1539 _ => Self::UnknownValue(model_version::UnknownValue(
1540 wkt::internal::UnknownEnumValue::Integer(value),
1541 )),
1542 }
1543 }
1544 }
1545
1546 impl std::convert::From<&str> for ModelVersion {
1547 fn from(value: &str) -> Self {
1548 use std::string::ToString;
1549 match value {
1550 "MODEL_VERSION_UNSPECIFIED" => Self::Unspecified,
1551 "MODEL_VERSION_1" => Self::ModelVersion1,
1552 "MODEL_VERSION_2" => Self::ModelVersion2,
1553 _ => Self::UnknownValue(model_version::UnknownValue(
1554 wkt::internal::UnknownEnumValue::String(value.to_string()),
1555 )),
1556 }
1557 }
1558 }
1559
1560 impl serde::ser::Serialize for ModelVersion {
1561 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1562 where
1563 S: serde::Serializer,
1564 {
1565 match self {
1566 Self::Unspecified => serializer.serialize_i32(0),
1567 Self::ModelVersion1 => serializer.serialize_i32(1),
1568 Self::ModelVersion2 => serializer.serialize_i32(2),
1569 Self::UnknownValue(u) => u.0.serialize(serializer),
1570 }
1571 }
1572 }
1573
1574 impl<'de> serde::de::Deserialize<'de> for ModelVersion {
1575 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1576 where
1577 D: serde::Deserializer<'de>,
1578 {
1579 deserializer.deserialize_any(wkt::internal::EnumVisitor::<ModelVersion>::new(
1580 ".google.cloud.language.v2.ModerateTextRequest.ModelVersion",
1581 ))
1582 }
1583 }
1584}
1585
1586#[derive(Clone, Default, PartialEq)]
1588#[non_exhaustive]
1589pub struct ModerateTextResponse {
1590 pub moderation_categories: std::vec::Vec<crate::model::ClassificationCategory>,
1592
1593 pub language_code: std::string::String,
1597
1598 pub language_supported: bool,
1602
1603 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1604}
1605
1606impl ModerateTextResponse {
1607 pub fn new() -> Self {
1608 std::default::Default::default()
1609 }
1610
1611 pub fn set_moderation_categories<T, V>(mut self, v: T) -> Self
1613 where
1614 T: std::iter::IntoIterator<Item = V>,
1615 V: std::convert::Into<crate::model::ClassificationCategory>,
1616 {
1617 use std::iter::Iterator;
1618 self.moderation_categories = v.into_iter().map(|i| i.into()).collect();
1619 self
1620 }
1621
1622 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1624 self.language_code = v.into();
1625 self
1626 }
1627
1628 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1630 self.language_supported = v.into();
1631 self
1632 }
1633}
1634
1635impl wkt::message::Message for ModerateTextResponse {
1636 fn typename() -> &'static str {
1637 "type.googleapis.com/google.cloud.language.v2.ModerateTextResponse"
1638 }
1639}
1640
1641#[derive(Clone, Default, PartialEq)]
1644#[non_exhaustive]
1645pub struct AnnotateTextRequest {
1646 pub document: std::option::Option<crate::model::Document>,
1648
1649 pub features: std::option::Option<crate::model::annotate_text_request::Features>,
1651
1652 pub encoding_type: crate::model::EncodingType,
1654
1655 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1656}
1657
1658impl AnnotateTextRequest {
1659 pub fn new() -> Self {
1660 std::default::Default::default()
1661 }
1662
1663 pub fn set_document<T>(mut self, v: T) -> Self
1665 where
1666 T: std::convert::Into<crate::model::Document>,
1667 {
1668 self.document = std::option::Option::Some(v.into());
1669 self
1670 }
1671
1672 pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
1674 where
1675 T: std::convert::Into<crate::model::Document>,
1676 {
1677 self.document = v.map(|x| x.into());
1678 self
1679 }
1680
1681 pub fn set_features<T>(mut self, v: T) -> Self
1683 where
1684 T: std::convert::Into<crate::model::annotate_text_request::Features>,
1685 {
1686 self.features = std::option::Option::Some(v.into());
1687 self
1688 }
1689
1690 pub fn set_or_clear_features<T>(mut self, v: std::option::Option<T>) -> Self
1692 where
1693 T: std::convert::Into<crate::model::annotate_text_request::Features>,
1694 {
1695 self.features = v.map(|x| x.into());
1696 self
1697 }
1698
1699 pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
1701 mut self,
1702 v: T,
1703 ) -> Self {
1704 self.encoding_type = v.into();
1705 self
1706 }
1707}
1708
1709impl wkt::message::Message for AnnotateTextRequest {
1710 fn typename() -> &'static str {
1711 "type.googleapis.com/google.cloud.language.v2.AnnotateTextRequest"
1712 }
1713}
1714
1715pub mod annotate_text_request {
1717 #[allow(unused_imports)]
1718 use super::*;
1719
1720 #[derive(Clone, Default, PartialEq)]
1723 #[non_exhaustive]
1724 pub struct Features {
1725 pub extract_entities: bool,
1727
1728 pub extract_document_sentiment: bool,
1730
1731 pub classify_text: bool,
1733
1734 pub moderate_text: bool,
1736
1737 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1738 }
1739
1740 impl Features {
1741 pub fn new() -> Self {
1742 std::default::Default::default()
1743 }
1744
1745 pub fn set_extract_entities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1747 self.extract_entities = v.into();
1748 self
1749 }
1750
1751 pub fn set_extract_document_sentiment<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1753 self.extract_document_sentiment = v.into();
1754 self
1755 }
1756
1757 pub fn set_classify_text<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1759 self.classify_text = v.into();
1760 self
1761 }
1762
1763 pub fn set_moderate_text<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1765 self.moderate_text = v.into();
1766 self
1767 }
1768 }
1769
1770 impl wkt::message::Message for Features {
1771 fn typename() -> &'static str {
1772 "type.googleapis.com/google.cloud.language.v2.AnnotateTextRequest.Features"
1773 }
1774 }
1775}
1776
1777#[derive(Clone, Default, PartialEq)]
1779#[non_exhaustive]
1780pub struct AnnotateTextResponse {
1781 pub sentences: std::vec::Vec<crate::model::Sentence>,
1786
1787 pub entities: std::vec::Vec<crate::model::Entity>,
1795
1796 pub document_sentiment: std::option::Option<crate::model::Sentiment>,
1801
1802 pub language_code: std::string::String,
1806
1807 pub categories: std::vec::Vec<crate::model::ClassificationCategory>,
1809
1810 pub moderation_categories: std::vec::Vec<crate::model::ClassificationCategory>,
1812
1813 pub language_supported: bool,
1817
1818 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1819}
1820
1821impl AnnotateTextResponse {
1822 pub fn new() -> Self {
1823 std::default::Default::default()
1824 }
1825
1826 pub fn set_sentences<T, V>(mut self, v: T) -> Self
1828 where
1829 T: std::iter::IntoIterator<Item = V>,
1830 V: std::convert::Into<crate::model::Sentence>,
1831 {
1832 use std::iter::Iterator;
1833 self.sentences = v.into_iter().map(|i| i.into()).collect();
1834 self
1835 }
1836
1837 pub fn set_entities<T, V>(mut self, v: T) -> Self
1839 where
1840 T: std::iter::IntoIterator<Item = V>,
1841 V: std::convert::Into<crate::model::Entity>,
1842 {
1843 use std::iter::Iterator;
1844 self.entities = v.into_iter().map(|i| i.into()).collect();
1845 self
1846 }
1847
1848 pub fn set_document_sentiment<T>(mut self, v: T) -> Self
1850 where
1851 T: std::convert::Into<crate::model::Sentiment>,
1852 {
1853 self.document_sentiment = std::option::Option::Some(v.into());
1854 self
1855 }
1856
1857 pub fn set_or_clear_document_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
1859 where
1860 T: std::convert::Into<crate::model::Sentiment>,
1861 {
1862 self.document_sentiment = v.map(|x| x.into());
1863 self
1864 }
1865
1866 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1868 self.language_code = v.into();
1869 self
1870 }
1871
1872 pub fn set_categories<T, V>(mut self, v: T) -> Self
1874 where
1875 T: std::iter::IntoIterator<Item = V>,
1876 V: std::convert::Into<crate::model::ClassificationCategory>,
1877 {
1878 use std::iter::Iterator;
1879 self.categories = v.into_iter().map(|i| i.into()).collect();
1880 self
1881 }
1882
1883 pub fn set_moderation_categories<T, V>(mut self, v: T) -> Self
1885 where
1886 T: std::iter::IntoIterator<Item = V>,
1887 V: std::convert::Into<crate::model::ClassificationCategory>,
1888 {
1889 use std::iter::Iterator;
1890 self.moderation_categories = v.into_iter().map(|i| i.into()).collect();
1891 self
1892 }
1893
1894 pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1896 self.language_supported = v.into();
1897 self
1898 }
1899}
1900
1901impl wkt::message::Message for AnnotateTextResponse {
1902 fn typename() -> &'static str {
1903 "type.googleapis.com/google.cloud.language.v2.AnnotateTextResponse"
1904 }
1905}
1906
1907#[derive(Clone, Debug, PartialEq)]
1927#[non_exhaustive]
1928pub enum EncodingType {
1929 None,
1932 Utf8,
1936 Utf16,
1940 Utf32,
1944 UnknownValue(encoding_type::UnknownValue),
1949}
1950
1951#[doc(hidden)]
1952pub mod encoding_type {
1953 #[allow(unused_imports)]
1954 use super::*;
1955 #[derive(Clone, Debug, PartialEq)]
1956 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1957}
1958
1959impl EncodingType {
1960 pub fn value(&self) -> std::option::Option<i32> {
1965 match self {
1966 Self::None => std::option::Option::Some(0),
1967 Self::Utf8 => std::option::Option::Some(1),
1968 Self::Utf16 => std::option::Option::Some(2),
1969 Self::Utf32 => std::option::Option::Some(3),
1970 Self::UnknownValue(u) => u.0.value(),
1971 }
1972 }
1973
1974 pub fn name(&self) -> std::option::Option<&str> {
1979 match self {
1980 Self::None => std::option::Option::Some("NONE"),
1981 Self::Utf8 => std::option::Option::Some("UTF8"),
1982 Self::Utf16 => std::option::Option::Some("UTF16"),
1983 Self::Utf32 => std::option::Option::Some("UTF32"),
1984 Self::UnknownValue(u) => u.0.name(),
1985 }
1986 }
1987}
1988
1989impl std::default::Default for EncodingType {
1990 fn default() -> Self {
1991 use std::convert::From;
1992 Self::from(0)
1993 }
1994}
1995
1996impl std::fmt::Display for EncodingType {
1997 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1998 wkt::internal::display_enum(f, self.name(), self.value())
1999 }
2000}
2001
2002impl std::convert::From<i32> for EncodingType {
2003 fn from(value: i32) -> Self {
2004 match value {
2005 0 => Self::None,
2006 1 => Self::Utf8,
2007 2 => Self::Utf16,
2008 3 => Self::Utf32,
2009 _ => Self::UnknownValue(encoding_type::UnknownValue(
2010 wkt::internal::UnknownEnumValue::Integer(value),
2011 )),
2012 }
2013 }
2014}
2015
2016impl std::convert::From<&str> for EncodingType {
2017 fn from(value: &str) -> Self {
2018 use std::string::ToString;
2019 match value {
2020 "NONE" => Self::None,
2021 "UTF8" => Self::Utf8,
2022 "UTF16" => Self::Utf16,
2023 "UTF32" => Self::Utf32,
2024 _ => Self::UnknownValue(encoding_type::UnknownValue(
2025 wkt::internal::UnknownEnumValue::String(value.to_string()),
2026 )),
2027 }
2028 }
2029}
2030
2031impl serde::ser::Serialize for EncodingType {
2032 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2033 where
2034 S: serde::Serializer,
2035 {
2036 match self {
2037 Self::None => serializer.serialize_i32(0),
2038 Self::Utf8 => serializer.serialize_i32(1),
2039 Self::Utf16 => serializer.serialize_i32(2),
2040 Self::Utf32 => serializer.serialize_i32(3),
2041 Self::UnknownValue(u) => u.0.serialize(serializer),
2042 }
2043 }
2044}
2045
2046impl<'de> serde::de::Deserialize<'de> for EncodingType {
2047 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2048 where
2049 D: serde::Deserializer<'de>,
2050 {
2051 deserializer.deserialize_any(wkt::internal::EnumVisitor::<EncodingType>::new(
2052 ".google.cloud.language.v2.EncodingType",
2053 ))
2054 }
2055}