pub trait StreamingHandler<Req, Res>:
Send
+ Sync
+ 'static{
type Item: Encodable<Res> + Send + 'static;
// Required method
fn call(
&self,
ctx: RequestContext,
request: Req,
) -> BoxFuture<'static, ServiceResult<ServiceStream<Self::Item>>>;
}Expand description
Trait for server streaming RPC handlers.
§Migrating from connectrpc 0.4.x
Item is new in 0.5: a hand-written impl StreamingHandler previously
returned ServiceStream<Res>; add type Item = Res; to keep the same
behavior. Generated traits and the streaming_handler_fn helper
infer it.
Required Associated Types§
Sourcetype Item: Encodable<Res> + Send + 'static
type Item: Encodable<Res> + Send + 'static
The stream item type. Typically Res itself; may be
PreEncoded or
MaybeBorrowed for handlers that encode
borrowing views per item.
Items must be 'static — a stream item cannot borrow &self or a
per-call snapshot. To stream view-encoded data, encode each item
inside the stream’s body and yield PreEncoded.
Required Methods§
Sourcefn call(
&self,
ctx: RequestContext,
request: Req,
) -> BoxFuture<'static, ServiceResult<ServiceStream<Self::Item>>>
fn call( &self, ctx: RequestContext, request: Req, ) -> BoxFuture<'static, ServiceResult<ServiceStream<Self::Item>>>
Handle a server streaming RPC request.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".