pub struct SessionsClient { /* private fields */ }
Expand description
Google Dialogflow sessions client. Used for detect intent API. Is cloneable!
Implementations
sourceimpl SessionsClient
impl SessionsClient
sourcepub async fn create(google_credentials: impl AsRef<str>) -> Result<Self>
pub async fn create(google_credentials: impl AsRef<str>) -> Result<Self>
Creates new sessions client using GCP project JSON credentials This client should be used for synchronous invocation (detect_intent)
sourcepub fn get_audio_sink(&mut self) -> Option<Sender<StreamingDetectIntentRequest>>
pub fn get_audio_sink(&mut self) -> Option<Sender<StreamingDetectIntentRequest>>
Returns sender than can be used to stream in audio bytes. This method will take the sender out of the option leaving None in its place. No additional sender can be retrieved from session client after this call. When sender is dropped respective stream will be closed.
sourcepub fn take_audio_sink(
&mut self
) -> Option<Sender<StreamingDetectIntentRequest>>
pub fn take_audio_sink(
&mut self
) -> Option<Sender<StreamingDetectIntentRequest>>
Returns sender than can be used to stream in audio bytes. This method will take the sender out of the option leaving None in its place. No additional sender can be retrieved from session client after this call. When sender is dropped respective stream will be closed.
sourcepub fn drop_audio_sink(&mut self)
pub fn drop_audio_sink(&mut self)
Drops audio sender so that respective stream can be closed.
sourcepub fn streaming_request_from_bytes(
session: String,
audio_bytes: Vec<u8>
) -> StreamingDetectIntentRequest
pub fn streaming_request_from_bytes(
session: String,
audio_bytes: Vec<u8>
) -> StreamingDetectIntentRequest
Convenience function so that client does not have to create full StreamingDetectIntentRequest and can just pass audio bytes vector instead.
sourcepub async fn detect_intent(
&mut self,
request: DetectIntentRequest
) -> Result<DetectIntentResponse>
pub async fn detect_intent(
&mut self,
request: DetectIntentRequest
) -> Result<DetectIntentResponse>
Calls detect_intent API of underlying GRPC SessionClient.
sourcepub fn is_eoc(response: &DetectIntentResponse) -> bool
pub fn is_eoc(response: &DetectIntentResponse) -> bool
Convenience function to check if DetectIntentResponse represents end of conversation. If so, returns true, otherwise false.
sourcepub fn get_session_string(project_id: &str, session_id: &str) -> String
pub fn get_session_string(project_id: &str, session_id: &str) -> String
Convenience function to return properly formatted session string for detect intent call.
Trait Implementations
sourceimpl Clone for SessionsClient
impl Clone for SessionsClient
sourcefn clone(&self) -> SessionsClient
fn clone(&self) -> SessionsClient
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for SessionsClient
impl Send for SessionsClient
impl Sync for SessionsClient
impl Unpin for SessionsClient
impl !UnwindSafe for SessionsClient
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message T
in a tonic::Request