#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gaxi;
extern crate google_cloud_gax;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;
mod debug;
mod deserialize;
mod serialize;
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Document {
pub r#type: crate::model::document::Type,
pub language_code: std::string::String,
pub source: std::option::Option<crate::model::document::Source>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Document {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_type<T: std::convert::Into<crate::model::document::Type>>(mut self, v: T) -> Self {
self.r#type = v.into();
self
}
pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.language_code = v.into();
self
}
pub fn set_source<
T: std::convert::Into<std::option::Option<crate::model::document::Source>>,
>(
mut self,
v: T,
) -> Self {
self.source = v.into();
self
}
pub fn content(&self) -> std::option::Option<&std::string::String> {
#[allow(unreachable_patterns)]
self.source.as_ref().and_then(|v| match v {
crate::model::document::Source::Content(v) => std::option::Option::Some(v),
_ => std::option::Option::None,
})
}
pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.source = std::option::Option::Some(crate::model::document::Source::Content(v.into()));
self
}
pub fn gcs_content_uri(&self) -> std::option::Option<&std::string::String> {
#[allow(unreachable_patterns)]
self.source.as_ref().and_then(|v| match v {
crate::model::document::Source::GcsContentUri(v) => std::option::Option::Some(v),
_ => std::option::Option::None,
})
}
pub fn set_gcs_content_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.source =
std::option::Option::Some(crate::model::document::Source::GcsContentUri(v.into()));
self
}
}
impl wkt::message::Message for Document {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.Document"
}
}
pub mod document {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Type {
Unspecified,
PlainText,
Html,
UnknownValue(r#type::UnknownValue),
}
#[doc(hidden)]
pub mod r#type {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl Type {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Unspecified => std::option::Option::Some(0),
Self::PlainText => std::option::Option::Some(1),
Self::Html => std::option::Option::Some(2),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
Self::PlainText => std::option::Option::Some("PLAIN_TEXT"),
Self::Html => std::option::Option::Some("HTML"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for Type {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for Type {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for Type {
fn from(value: i32) -> Self {
match value {
0 => Self::Unspecified,
1 => Self::PlainText,
2 => Self::Html,
_ => Self::UnknownValue(r#type::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for Type {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"TYPE_UNSPECIFIED" => Self::Unspecified,
"PLAIN_TEXT" => Self::PlainText,
"HTML" => Self::Html,
_ => Self::UnknownValue(r#type::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for Type {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Unspecified => serializer.serialize_i32(0),
Self::PlainText => serializer.serialize_i32(1),
Self::Html => serializer.serialize_i32(2),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for Type {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
".google.cloud.language.v2.Document.Type",
))
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Source {
Content(std::string::String),
GcsContentUri(std::string::String),
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Sentence {
pub text: std::option::Option<crate::model::TextSpan>,
pub sentiment: std::option::Option<crate::model::Sentiment>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Sentence {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_text<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::TextSpan>,
{
self.text = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_text<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::TextSpan>,
{
self.text = v.map(|x| x.into());
self
}
pub fn set_sentiment<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::Sentiment>,
{
self.sentiment = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::Sentiment>,
{
self.sentiment = v.map(|x| x.into());
self
}
}
impl wkt::message::Message for Sentence {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.Sentence"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Entity {
pub name: std::string::String,
pub r#type: crate::model::entity::Type,
pub metadata: std::collections::HashMap<std::string::String, std::string::String>,
pub mentions: std::vec::Vec<crate::model::EntityMention>,
pub sentiment: std::option::Option<crate::model::Sentiment>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Entity {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_type<T: std::convert::Into<crate::model::entity::Type>>(mut self, v: T) -> Self {
self.r#type = v.into();
self
}
pub fn set_metadata<T, K, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = (K, V)>,
K: std::convert::Into<std::string::String>,
V: std::convert::Into<std::string::String>,
{
use std::iter::Iterator;
self.metadata = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
self
}
pub fn set_mentions<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::EntityMention>,
{
use std::iter::Iterator;
self.mentions = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_sentiment<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::Sentiment>,
{
self.sentiment = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::Sentiment>,
{
self.sentiment = v.map(|x| x.into());
self
}
}
impl wkt::message::Message for Entity {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.Entity"
}
}
pub mod entity {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Type {
Unknown,
Person,
Location,
Organization,
Event,
WorkOfArt,
ConsumerGood,
Other,
PhoneNumber,
Address,
Date,
Number,
Price,
UnknownValue(r#type::UnknownValue),
}
#[doc(hidden)]
pub mod r#type {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl Type {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Unknown => std::option::Option::Some(0),
Self::Person => std::option::Option::Some(1),
Self::Location => std::option::Option::Some(2),
Self::Organization => std::option::Option::Some(3),
Self::Event => std::option::Option::Some(4),
Self::WorkOfArt => std::option::Option::Some(5),
Self::ConsumerGood => std::option::Option::Some(6),
Self::Other => std::option::Option::Some(7),
Self::PhoneNumber => std::option::Option::Some(9),
Self::Address => std::option::Option::Some(10),
Self::Date => std::option::Option::Some(11),
Self::Number => std::option::Option::Some(12),
Self::Price => std::option::Option::Some(13),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Unknown => std::option::Option::Some("UNKNOWN"),
Self::Person => std::option::Option::Some("PERSON"),
Self::Location => std::option::Option::Some("LOCATION"),
Self::Organization => std::option::Option::Some("ORGANIZATION"),
Self::Event => std::option::Option::Some("EVENT"),
Self::WorkOfArt => std::option::Option::Some("WORK_OF_ART"),
Self::ConsumerGood => std::option::Option::Some("CONSUMER_GOOD"),
Self::Other => std::option::Option::Some("OTHER"),
Self::PhoneNumber => std::option::Option::Some("PHONE_NUMBER"),
Self::Address => std::option::Option::Some("ADDRESS"),
Self::Date => std::option::Option::Some("DATE"),
Self::Number => std::option::Option::Some("NUMBER"),
Self::Price => std::option::Option::Some("PRICE"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for Type {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for Type {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for Type {
fn from(value: i32) -> Self {
match value {
0 => Self::Unknown,
1 => Self::Person,
2 => Self::Location,
3 => Self::Organization,
4 => Self::Event,
5 => Self::WorkOfArt,
6 => Self::ConsumerGood,
7 => Self::Other,
9 => Self::PhoneNumber,
10 => Self::Address,
11 => Self::Date,
12 => Self::Number,
13 => Self::Price,
_ => Self::UnknownValue(r#type::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for Type {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"UNKNOWN" => Self::Unknown,
"PERSON" => Self::Person,
"LOCATION" => Self::Location,
"ORGANIZATION" => Self::Organization,
"EVENT" => Self::Event,
"WORK_OF_ART" => Self::WorkOfArt,
"CONSUMER_GOOD" => Self::ConsumerGood,
"OTHER" => Self::Other,
"PHONE_NUMBER" => Self::PhoneNumber,
"ADDRESS" => Self::Address,
"DATE" => Self::Date,
"NUMBER" => Self::Number,
"PRICE" => Self::Price,
_ => Self::UnknownValue(r#type::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for Type {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Unknown => serializer.serialize_i32(0),
Self::Person => serializer.serialize_i32(1),
Self::Location => serializer.serialize_i32(2),
Self::Organization => serializer.serialize_i32(3),
Self::Event => serializer.serialize_i32(4),
Self::WorkOfArt => serializer.serialize_i32(5),
Self::ConsumerGood => serializer.serialize_i32(6),
Self::Other => serializer.serialize_i32(7),
Self::PhoneNumber => serializer.serialize_i32(9),
Self::Address => serializer.serialize_i32(10),
Self::Date => serializer.serialize_i32(11),
Self::Number => serializer.serialize_i32(12),
Self::Price => serializer.serialize_i32(13),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for Type {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
".google.cloud.language.v2.Entity.Type",
))
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Sentiment {
pub magnitude: f32,
pub score: f32,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Sentiment {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_magnitude<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
self.magnitude = v.into();
self
}
pub fn set_score<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
self.score = v.into();
self
}
}
impl wkt::message::Message for Sentiment {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.Sentiment"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct EntityMention {
pub text: std::option::Option<crate::model::TextSpan>,
pub r#type: crate::model::entity_mention::Type,
pub sentiment: std::option::Option<crate::model::Sentiment>,
pub probability: f32,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl EntityMention {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_text<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::TextSpan>,
{
self.text = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_text<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::TextSpan>,
{
self.text = v.map(|x| x.into());
self
}
pub fn set_type<T: std::convert::Into<crate::model::entity_mention::Type>>(
mut self,
v: T,
) -> Self {
self.r#type = v.into();
self
}
pub fn set_sentiment<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::Sentiment>,
{
self.sentiment = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::Sentiment>,
{
self.sentiment = v.map(|x| x.into());
self
}
pub fn set_probability<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
self.probability = v.into();
self
}
}
impl wkt::message::Message for EntityMention {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.EntityMention"
}
}
pub mod entity_mention {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Type {
Unknown,
Proper,
Common,
UnknownValue(r#type::UnknownValue),
}
#[doc(hidden)]
pub mod r#type {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl Type {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Unknown => std::option::Option::Some(0),
Self::Proper => std::option::Option::Some(1),
Self::Common => std::option::Option::Some(2),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Unknown => std::option::Option::Some("TYPE_UNKNOWN"),
Self::Proper => std::option::Option::Some("PROPER"),
Self::Common => std::option::Option::Some("COMMON"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for Type {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for Type {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for Type {
fn from(value: i32) -> Self {
match value {
0 => Self::Unknown,
1 => Self::Proper,
2 => Self::Common,
_ => Self::UnknownValue(r#type::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for Type {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"TYPE_UNKNOWN" => Self::Unknown,
"PROPER" => Self::Proper,
"COMMON" => Self::Common,
_ => Self::UnknownValue(r#type::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for Type {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Unknown => serializer.serialize_i32(0),
Self::Proper => serializer.serialize_i32(1),
Self::Common => serializer.serialize_i32(2),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for Type {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
".google.cloud.language.v2.EntityMention.Type",
))
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct TextSpan {
pub content: std::string::String,
pub begin_offset: i32,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl TextSpan {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.content = v.into();
self
}
pub fn set_begin_offset<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.begin_offset = v.into();
self
}
}
impl wkt::message::Message for TextSpan {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.TextSpan"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ClassificationCategory {
pub name: std::string::String,
pub confidence: f32,
pub severity: f32,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl ClassificationCategory {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_confidence<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
self.confidence = v.into();
self
}
pub fn set_severity<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
self.severity = v.into();
self
}
}
impl wkt::message::Message for ClassificationCategory {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.ClassificationCategory"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AnalyzeSentimentRequest {
pub document: std::option::Option<crate::model::Document>,
pub encoding_type: crate::model::EncodingType,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl AnalyzeSentimentRequest {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_document<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::Document>,
{
self.document = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::Document>,
{
self.document = v.map(|x| x.into());
self
}
pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
mut self,
v: T,
) -> Self {
self.encoding_type = v.into();
self
}
}
impl wkt::message::Message for AnalyzeSentimentRequest {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.AnalyzeSentimentRequest"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AnalyzeSentimentResponse {
pub document_sentiment: std::option::Option<crate::model::Sentiment>,
pub language_code: std::string::String,
pub sentences: std::vec::Vec<crate::model::Sentence>,
pub language_supported: bool,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl AnalyzeSentimentResponse {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_document_sentiment<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::Sentiment>,
{
self.document_sentiment = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_document_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::Sentiment>,
{
self.document_sentiment = v.map(|x| x.into());
self
}
pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.language_code = v.into();
self
}
pub fn set_sentences<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::Sentence>,
{
use std::iter::Iterator;
self.sentences = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.language_supported = v.into();
self
}
}
impl wkt::message::Message for AnalyzeSentimentResponse {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.AnalyzeSentimentResponse"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AnalyzeEntitiesRequest {
pub document: std::option::Option<crate::model::Document>,
pub encoding_type: crate::model::EncodingType,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl AnalyzeEntitiesRequest {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_document<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::Document>,
{
self.document = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::Document>,
{
self.document = v.map(|x| x.into());
self
}
pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
mut self,
v: T,
) -> Self {
self.encoding_type = v.into();
self
}
}
impl wkt::message::Message for AnalyzeEntitiesRequest {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.AnalyzeEntitiesRequest"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AnalyzeEntitiesResponse {
pub entities: std::vec::Vec<crate::model::Entity>,
pub language_code: std::string::String,
pub language_supported: bool,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl AnalyzeEntitiesResponse {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_entities<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::Entity>,
{
use std::iter::Iterator;
self.entities = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.language_code = v.into();
self
}
pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.language_supported = v.into();
self
}
}
impl wkt::message::Message for AnalyzeEntitiesResponse {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.AnalyzeEntitiesResponse"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ClassifyTextRequest {
pub document: std::option::Option<crate::model::Document>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl ClassifyTextRequest {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_document<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::Document>,
{
self.document = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::Document>,
{
self.document = v.map(|x| x.into());
self
}
}
impl wkt::message::Message for ClassifyTextRequest {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.ClassifyTextRequest"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ClassifyTextResponse {
pub categories: std::vec::Vec<crate::model::ClassificationCategory>,
pub language_code: std::string::String,
pub language_supported: bool,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl ClassifyTextResponse {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_categories<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::ClassificationCategory>,
{
use std::iter::Iterator;
self.categories = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.language_code = v.into();
self
}
pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.language_supported = v.into();
self
}
}
impl wkt::message::Message for ClassifyTextResponse {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.ClassifyTextResponse"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ModerateTextRequest {
pub document: std::option::Option<crate::model::Document>,
pub model_version: crate::model::moderate_text_request::ModelVersion,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl ModerateTextRequest {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_document<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::Document>,
{
self.document = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::Document>,
{
self.document = v.map(|x| x.into());
self
}
pub fn set_model_version<
T: std::convert::Into<crate::model::moderate_text_request::ModelVersion>,
>(
mut self,
v: T,
) -> Self {
self.model_version = v.into();
self
}
}
impl wkt::message::Message for ModerateTextRequest {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.ModerateTextRequest"
}
}
pub mod moderate_text_request {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum ModelVersion {
Unspecified,
ModelVersion1,
ModelVersion2,
UnknownValue(model_version::UnknownValue),
}
#[doc(hidden)]
pub mod model_version {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl ModelVersion {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Unspecified => std::option::Option::Some(0),
Self::ModelVersion1 => std::option::Option::Some(1),
Self::ModelVersion2 => std::option::Option::Some(2),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Unspecified => std::option::Option::Some("MODEL_VERSION_UNSPECIFIED"),
Self::ModelVersion1 => std::option::Option::Some("MODEL_VERSION_1"),
Self::ModelVersion2 => std::option::Option::Some("MODEL_VERSION_2"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for ModelVersion {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for ModelVersion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for ModelVersion {
fn from(value: i32) -> Self {
match value {
0 => Self::Unspecified,
1 => Self::ModelVersion1,
2 => Self::ModelVersion2,
_ => Self::UnknownValue(model_version::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for ModelVersion {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"MODEL_VERSION_UNSPECIFIED" => Self::Unspecified,
"MODEL_VERSION_1" => Self::ModelVersion1,
"MODEL_VERSION_2" => Self::ModelVersion2,
_ => Self::UnknownValue(model_version::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for ModelVersion {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Unspecified => serializer.serialize_i32(0),
Self::ModelVersion1 => serializer.serialize_i32(1),
Self::ModelVersion2 => serializer.serialize_i32(2),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for ModelVersion {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<ModelVersion>::new(
".google.cloud.language.v2.ModerateTextRequest.ModelVersion",
))
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ModerateTextResponse {
pub moderation_categories: std::vec::Vec<crate::model::ClassificationCategory>,
pub language_code: std::string::String,
pub language_supported: bool,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl ModerateTextResponse {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_moderation_categories<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::ClassificationCategory>,
{
use std::iter::Iterator;
self.moderation_categories = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.language_code = v.into();
self
}
pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.language_supported = v.into();
self
}
}
impl wkt::message::Message for ModerateTextResponse {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.ModerateTextResponse"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AnnotateTextRequest {
pub document: std::option::Option<crate::model::Document>,
pub features: std::option::Option<crate::model::annotate_text_request::Features>,
pub encoding_type: crate::model::EncodingType,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl AnnotateTextRequest {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_document<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::Document>,
{
self.document = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::Document>,
{
self.document = v.map(|x| x.into());
self
}
pub fn set_features<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::annotate_text_request::Features>,
{
self.features = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_features<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::annotate_text_request::Features>,
{
self.features = v.map(|x| x.into());
self
}
pub fn set_encoding_type<T: std::convert::Into<crate::model::EncodingType>>(
mut self,
v: T,
) -> Self {
self.encoding_type = v.into();
self
}
}
impl wkt::message::Message for AnnotateTextRequest {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.AnnotateTextRequest"
}
}
pub mod annotate_text_request {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Features {
pub extract_entities: bool,
pub extract_document_sentiment: bool,
pub classify_text: bool,
pub moderate_text: bool,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Features {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_extract_entities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.extract_entities = v.into();
self
}
pub fn set_extract_document_sentiment<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.extract_document_sentiment = v.into();
self
}
pub fn set_classify_text<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.classify_text = v.into();
self
}
pub fn set_moderate_text<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.moderate_text = v.into();
self
}
}
impl wkt::message::Message for Features {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.AnnotateTextRequest.Features"
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AnnotateTextResponse {
pub sentences: std::vec::Vec<crate::model::Sentence>,
pub entities: std::vec::Vec<crate::model::Entity>,
pub document_sentiment: std::option::Option<crate::model::Sentiment>,
pub language_code: std::string::String,
pub categories: std::vec::Vec<crate::model::ClassificationCategory>,
pub moderation_categories: std::vec::Vec<crate::model::ClassificationCategory>,
pub language_supported: bool,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl AnnotateTextResponse {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_sentences<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::Sentence>,
{
use std::iter::Iterator;
self.sentences = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_entities<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::Entity>,
{
use std::iter::Iterator;
self.entities = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_document_sentiment<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::Sentiment>,
{
self.document_sentiment = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_document_sentiment<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::Sentiment>,
{
self.document_sentiment = v.map(|x| x.into());
self
}
pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.language_code = v.into();
self
}
pub fn set_categories<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::ClassificationCategory>,
{
use std::iter::Iterator;
self.categories = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_moderation_categories<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::ClassificationCategory>,
{
use std::iter::Iterator;
self.moderation_categories = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_language_supported<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
self.language_supported = v.into();
self
}
}
impl wkt::message::Message for AnnotateTextResponse {
fn typename() -> &'static str {
"type.googleapis.com/google.cloud.language.v2.AnnotateTextResponse"
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum EncodingType {
None,
Utf8,
Utf16,
Utf32,
UnknownValue(encoding_type::UnknownValue),
}
#[doc(hidden)]
pub mod encoding_type {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl EncodingType {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::None => std::option::Option::Some(0),
Self::Utf8 => std::option::Option::Some(1),
Self::Utf16 => std::option::Option::Some(2),
Self::Utf32 => std::option::Option::Some(3),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::None => std::option::Option::Some("NONE"),
Self::Utf8 => std::option::Option::Some("UTF8"),
Self::Utf16 => std::option::Option::Some("UTF16"),
Self::Utf32 => std::option::Option::Some("UTF32"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for EncodingType {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for EncodingType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for EncodingType {
fn from(value: i32) -> Self {
match value {
0 => Self::None,
1 => Self::Utf8,
2 => Self::Utf16,
3 => Self::Utf32,
_ => Self::UnknownValue(encoding_type::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for EncodingType {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"NONE" => Self::None,
"UTF8" => Self::Utf8,
"UTF16" => Self::Utf16,
"UTF32" => Self::Utf32,
_ => Self::UnknownValue(encoding_type::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for EncodingType {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::None => serializer.serialize_i32(0),
Self::Utf8 => serializer.serialize_i32(1),
Self::Utf16 => serializer.serialize_i32(2),
Self::Utf32 => serializer.serialize_i32(3),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for EncodingType {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<EncodingType>::new(
".google.cloud.language.v2.EncodingType",
))
}
}