gcp_sdk_language_v2/
builders.rspub mod language_service {
use crate::Result;
use std::sync::Arc;
#[derive(Clone, Debug)]
pub struct RequestBuilder<R: std::default::Default> {
stub: Arc<dyn crate::stubs::dynamic::LanguageService>,
request: R,
options: gax::options::RequestOptions,
}
impl<R> RequestBuilder<R>
where
R: std::default::Default,
{
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
Self {
stub,
request: R::default(),
options: gax::options::RequestOptions::default(),
}
}
}
#[derive(Clone, Debug)]
pub struct AnalyzeSentiment(RequestBuilder<crate::model::AnalyzeSentimentRequest>);
impl AnalyzeSentiment {
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::AnalyzeSentimentRequest>>(
mut self,
v: V,
) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<crate::model::AnalyzeSentimentResponse> {
(*self.0.stub)
.analyze_sentiment(self.0.request, self.0.options)
.await
}
pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
mut self,
v: T,
) -> Self {
self.0.request.document = v.into();
self
}
pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
self.0.request.encoding_type = v.into();
self
}
}
impl gax::options::RequestBuilder for AnalyzeSentiment {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct AnalyzeEntities(RequestBuilder<crate::model::AnalyzeEntitiesRequest>);
impl AnalyzeEntities {
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::AnalyzeEntitiesRequest>>(mut self, v: V) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<crate::model::AnalyzeEntitiesResponse> {
(*self.0.stub)
.analyze_entities(self.0.request, self.0.options)
.await
}
pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
mut self,
v: T,
) -> Self {
self.0.request.document = v.into();
self
}
pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
self.0.request.encoding_type = v.into();
self
}
}
impl gax::options::RequestBuilder for AnalyzeEntities {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct ClassifyText(RequestBuilder<crate::model::ClassifyTextRequest>);
impl ClassifyText {
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::ClassifyTextRequest>>(mut self, v: V) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<crate::model::ClassifyTextResponse> {
(*self.0.stub)
.classify_text(self.0.request, self.0.options)
.await
}
pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
mut self,
v: T,
) -> Self {
self.0.request.document = v.into();
self
}
}
impl gax::options::RequestBuilder for ClassifyText {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct ModerateText(RequestBuilder<crate::model::ModerateTextRequest>);
impl ModerateText {
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::ModerateTextRequest>>(mut self, v: V) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<crate::model::ModerateTextResponse> {
(*self.0.stub)
.moderate_text(self.0.request, self.0.options)
.await
}
pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
mut self,
v: T,
) -> Self {
self.0.request.document = v.into();
self
}
pub fn set_model_version<T: Into<crate::model::moderate_text_request::ModelVersion>>(
mut self,
v: T,
) -> Self {
self.0.request.model_version = v.into();
self
}
}
impl gax::options::RequestBuilder for ModerateText {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
#[derive(Clone, Debug)]
pub struct AnnotateText(RequestBuilder<crate::model::AnnotateTextRequest>);
impl AnnotateText {
pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::LanguageService>) -> Self {
Self(RequestBuilder::new(stub))
}
pub fn with_request<V: Into<crate::model::AnnotateTextRequest>>(mut self, v: V) -> Self {
self.0.request = v.into();
self
}
pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
pub async fn send(self) -> Result<crate::model::AnnotateTextResponse> {
(*self.0.stub)
.annotate_text(self.0.request, self.0.options)
.await
}
pub fn set_document<T: Into<std::option::Option<crate::model::Document>>>(
mut self,
v: T,
) -> Self {
self.0.request.document = v.into();
self
}
pub fn set_features<
T: Into<std::option::Option<crate::model::annotate_text_request::Features>>,
>(
mut self,
v: T,
) -> Self {
self.0.request.features = v.into();
self
}
pub fn set_encoding_type<T: Into<crate::model::EncodingType>>(mut self, v: T) -> Self {
self.0.request.encoding_type = v.into();
self
}
}
impl gax::options::RequestBuilder for AnnotateText {
fn request_options(&mut self) -> &mut gax::options::RequestOptions {
&mut self.0.options
}
}
}