pub struct StreamingResponse {
pub inner: Streaming<ResponseMessage>,
}
Expand description
Streaming requests and responses.
Fields§
§inner: Streaming<ResponseMessage>
Implementations§
Source§impl StreamingResponse
impl StreamingResponse
pub fn new(inner: Streaming<ResponseMessage>) -> Self
Methods from Deref<Target = Streaming<ResponseMessage>>§
Sourcepub async fn message(&mut self) -> Result<Option<T>, Status>
pub async fn message(&mut self) -> Result<Option<T>, Status>
Fetch the next message from this stream.
§Return value
-
Result::Err(val)
means a gRPC error was sent by the sender instead of a valid response message. Refer toStatus::code
andStatus::message
to examine possible error causes. -
Result::Ok(None)
means the stream was closed by the sender and no more messages will be delivered. Further attempts to callStreaming::message
will result in the same return value. -
Result::Ok(Some(val))
means the sender streamed a valid response messageval
.
if let Some(next_message) = request.message().await? {
println!("{:?}", next_message);
}
Sourcepub async fn trailers(&mut self) -> Result<Option<MetadataMap>, Status>
pub async fn trailers(&mut self) -> Result<Option<MetadataMap>, Status>
Fetch the trailing metadata.
This will drain the stream of all its messages to receive the trailing
metadata. If Streaming::message
returns None
then this function
will not need to poll for trailers since the body was totally consumed.
if let Some(metadata) = request.trailers().await? {
println!("{:?}", metadata);
}
Trait Implementations§
Source§impl Deref for StreamingResponse
impl Deref for StreamingResponse
Auto Trait Implementations§
impl !Freeze for StreamingResponse
impl !RefUnwindSafe for StreamingResponse
impl Send for StreamingResponse
impl !Sync for StreamingResponse
impl Unpin for StreamingResponse
impl !UnwindSafe for StreamingResponse
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