pub struct SessionsClient { /* private fields */ }
Expand description
Google Dialogflow sessions client. Used for streaming detect intent API. Is NOT cloneable!
Implementations
sourceimpl SessionsClient
impl SessionsClient
sourcepub async fn create(
google_credentials: impl AsRef<str>,
streaming_detect_intent_req: StreamingDetectIntentRequest,
buffer_size: Option<usize>
) -> Result<Self>
pub async fn create(
google_credentials: impl AsRef<str>,
streaming_detect_intent_req: StreamingDetectIntentRequest,
buffer_size: Option<usize>
) -> Result<Self>
Creates new sessions client using GCP project JSON credentials This client should be used for asynchronous invocation (streaming_detect_intent) See https://cloud.google.com/dialogflow/es/docs/how/detect-intent-stream
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 get_streaming_result_receiver(
&mut self,
buffer_size: Option<usize>
) -> Receiver<StreamingDetectIntentResponse>
pub fn get_streaming_result_receiver(
&mut self,
buffer_size: Option<usize>
) -> Receiver<StreamingDetectIntentResponse>
Returns receiver that can be used to receive streaming detect intents results
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 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.
sourcepub async fn streaming_detect_intent_async_stream(
&mut self
) -> impl Stream<Item = Result<StreamingDetectIntentResponse>> + '_
pub async fn streaming_detect_intent_async_stream(
&mut self
) -> impl Stream<Item = Result<StreamingDetectIntentResponse>> + '_
IMPORTANT: currently streaming_detect_intent does not work properly because half-close operation is not implemented. Details here(go example): https://cloud.google.com/dialogflow/es/docs/how/detect-intent-stream#detect-intent-stream-go
sourcepub async fn streaming_detect_intent(&mut self) -> Result<()>
pub async fn streaming_detect_intent(&mut self) -> Result<()>
Initiates bidirectional streaming. This call should be spawned into separate tokio task. Results can be then retrieved via channel receiver returned by method get_streaming_result_receiver. IMPORTANT: currently streaming_detect_intent does not work properly because half-close operation is not implemented. Details here(go example): https://cloud.google.com/dialogflow/es/docs/how/detect-intent-stream#detect-intent-stream-go
Trait Implementations
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