IntoStreamingRequest

Trait IntoStreamingRequest 

pub trait IntoStreamingRequest: Sealed {
    type Stream: Stream<Item = Self::Message> + Send + Sync + '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 rama_grpc::Requests. The purpose is to make client calls slightly more convenient to write.

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 rama_grpc::Request;

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

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

Required Associated Types§

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

The RPC request stream type

type Message

The RPC request type

Required Methods§

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

Wrap the stream of messages in a rama_grpc::Request

Implementors§

§

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

§

type Stream = T

§

type Message = <T as Stream>::Item

§

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

§

type Stream = T

§

type Message = <T as Stream>::Item