[][src]Trait tonic::IntoStreamingRequest

pub trait IntoStreamingRequest: Sealed {
    type Stream: Stream<Item = Self::Message> + Send + Sync + 'static;
    type Message;
    fn into_streaming_request(self) -> Request<Self::Stream>;
}

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;
use futures_util::stream;

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

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

Associated Types

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

The RPC request stream type

type Message

The RPC request type

Loading content...

Required methods

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

Wrap the stream of messages in a tonic::Request

Loading content...

Implementors

impl<T> IntoStreamingRequest for Request<T> where
    T: Stream + Send + Sync + 'static, 
[src]

type Stream = T

type Message = T::Item

impl<T> IntoStreamingRequest for T where
    T: Stream + Send + Sync + 'static, 
[src]

type Stream = T

type Message = T::Item

Loading content...