pub struct Session { /* private fields */ }Expand description
Represents an open subscribe session.
This is a stream-like struct for serving messages to an application.
§Example
let mut session = client
.streaming_pull("projects/my-project/subscriptions/my-subscription")
.start();
while let Some((m, h)) = session.next().await.transpose()? {
println!("Received message m={m:?}");
h.ack();
}Implementations§
Source§impl Session
impl Session
Sourcepub async fn next(&mut self) -> Option<Result<(PubsubMessage, Handler)>>
pub async fn next(&mut self) -> Option<Result<(PubsubMessage, Handler)>>
Returns the next message received on this subscription.
The message data is returned along with a Handler for acknowledging (ack) or rejecting (nack) the message.
If the underlying stream encounters a permanent error, an Error is
returned instead.
None represents the end of a stream, but in practice, the stream stays
open until it is cancelled or encounters a permanent error.
§Example
while let Some((m, h)) = session.next().await.transpose()? {
println!("Received message m={m:?}");
h.ack();
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl !UnwindSafe for Session
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request