Trait tonic::IntoStreamingRequest

source ·
pub trait IntoStreamingRequest: Sealed {
    type Stream: Stream<Item = Self::Message> + Send + 'static;
    type Message;

    // Required method
    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::Requests. 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;

let messages = vec![Point {}, Point {}];

client.record_route(Request::new(tokio_stream::iter(messages.clone())));
client.record_route(tokio_stream::iter(messages));

Required Associated Types§

source

type Stream: Stream<Item = Self::Message> + Send + 'static

The RPC request stream type

source

type Message

The RPC request type

Required Methods§

source

fn into_streaming_request(self) -> Request<Self::Stream>

Wrap the stream of messages in a tonic::Request

Implementors§

source§

impl<T> IntoStreamingRequest for Request<T>
where T: Stream + Send + 'static,

§

type Stream = T

§

type Message = <T as Stream>::Item

source§

impl<T> IntoStreamingRequest for T
where T: Stream + Send + 'static,

§

type Stream = T

§

type Message = <T as Stream>::Item