Struct quic_rpc::server::RpcChannel
source · pub struct RpcChannel<S: Service, C: ServiceEndpoint<S>> {
pub send: C::SendSink,
pub recv: C::RecvStream,
/* private fields */
}Expand description
A channel for requests and responses for a specific service.
This just groups the sink and stream into a single type, and attaches the information about the service type.
Sink and stream are independent, so you can take the channel apart and use them independently.
Fields§
§send: C::SendSinkSink to send responses to the client.
recv: C::RecvStreamStream to receive requests from the client.
Implementations§
source§impl<S: Service, C: ServiceEndpoint<S>> RpcChannel<S, C>
impl<S: Service, C: ServiceEndpoint<S>> RpcChannel<S, C>
sourcepub fn new(send: C::SendSink, recv: C::RecvStream) -> Self
pub fn new(send: C::SendSink, recv: C::RecvStream) -> Self
Create a new channel from a sink and a stream.
sourcepub async fn rpc<M, F, Fut, T>(
self,
req: M,
target: T,
f: F
) -> Result<(), RpcServerError<C>>
pub async fn rpc<M, F, Fut, T>( self, req: M, target: T, f: F ) -> Result<(), RpcServerError<C>>
handle the message of type M using the given function on the target object
If you want to support concurrent requests, you need to spawn this on a tokio task yourself.
sourcepub async fn client_streaming<M, F, Fut, T>(
self,
req: M,
target: T,
f: F
) -> Result<(), RpcServerError<C>>where
M: ClientStreamingMsg<S>,
F: FnOnce(T, M, UpdateStream<S, C, M::Update>) -> Fut + Send + 'static,
Fut: Future<Output = M::Response> + Send + 'static,
T: Send + 'static,
pub async fn client_streaming<M, F, Fut, T>(
self,
req: M,
target: T,
f: F
) -> Result<(), RpcServerError<C>>where
M: ClientStreamingMsg<S>,
F: FnOnce(T, M, UpdateStream<S, C, M::Update>) -> Fut + Send + 'static,
Fut: Future<Output = M::Response> + Send + 'static,
T: Send + 'static,
handle the message M using the given function on the target object
If you want to support concurrent requests, you need to spawn this on a tokio task yourself.
sourcepub async fn bidi_streaming<M, F, Str, T>(
self,
req: M,
target: T,
f: F
) -> Result<(), RpcServerError<C>>where
M: BidiStreamingMsg<S>,
F: FnOnce(T, M, UpdateStream<S, C, M::Update>) -> Str + Send + 'static,
Str: Stream<Item = M::Response> + Send + 'static,
T: Send + 'static,
pub async fn bidi_streaming<M, F, Str, T>(
self,
req: M,
target: T,
f: F
) -> Result<(), RpcServerError<C>>where
M: BidiStreamingMsg<S>,
F: FnOnce(T, M, UpdateStream<S, C, M::Update>) -> Str + Send + 'static,
Str: Stream<Item = M::Response> + Send + 'static,
T: Send + 'static,
handle the message M using the given function on the target object
If you want to support concurrent requests, you need to spawn this on a tokio task yourself.
sourcepub async fn server_streaming<M, F, Str, T>(
self,
req: M,
target: T,
f: F
) -> Result<(), RpcServerError<C>>
pub async fn server_streaming<M, F, Str, T>( self, req: M, target: T, f: F ) -> Result<(), RpcServerError<C>>
handle the message M using the given function on the target object
If you want to support concurrent requests, you need to spawn this on a tokio task yourself.
sourcepub async fn rpc_map_err<M, F, Fut, T, R, E1, E2>(
self,
req: M,
target: T,
f: F
) -> Result<(), RpcServerError<C>>
pub async fn rpc_map_err<M, F, Fut, T, R, E1, E2>( self, req: M, target: T, f: F ) -> Result<(), RpcServerError<C>>
A rpc call that also maps the error from the user type to the wire type
This is useful if you want to write your function with a convenient error type like anyhow::Error, yet still use a serializable error type on the wire.