Trait tonic::IntoStreamingRequest
source · [−]pub trait IntoStreamingRequest: Sealed {
type Stream: Stream<Item = Self::Message> + Send + 'static;
type Message;
fn into_streaming_request(self) -> Request<Self::Stream>;
}
Expand description
Trait implemented by RPC streaming request types.
Types implementing this trait can be used as arguments to client streaming
RPC methods without explicitly wrapping them into tonic::Request
s. The
purpose is to make client calls slightly more convenient to write.
Tonic’s code generation and blanket implementations handle this for you, so it is not necessary to implement this trait directly.
Example
Given the following gRPC service method definition:
rpc RecordRoute(stream Point) returns (RouteSummary) {}
we can call record_route
in two equivalent ways:
use tonic::Request;
use futures_util::stream;
let messages = vec![Point {}, Point {}];
client.record_route(Request::new(stream::iter(messages.clone())));
client.record_route(stream::iter(messages));
Required Associated Types
Required Methods
sourcefn into_streaming_request(self) -> Request<Self::Stream>
fn into_streaming_request(self) -> Request<Self::Stream>
Wrap the stream of messages in a tonic::Request