pub struct RpcServer<S, C> { /* private fields */ }
Expand description
A server channel for a specific service.
This is a wrapper around a ServiceEndpoint that serves as the entry point for the server DSL.
S
is the service type, C
is the channel type.
Implementations§
source§impl<S: Service, C: ServiceEndpoint<S>> RpcServer<S, C>
impl<S: Service, C: ServiceEndpoint<S>> RpcServer<S, C>
sourcepub fn new(source: C) -> Self
pub fn new(source: C) -> Self
Create a new rpc server for a specific service for a Service given a compatible ServiceEndpoint.
This is where a generic typed endpoint is converted into a server for a specific service.
source§impl<S: Service, C: ServiceEndpoint<S>> RpcServer<S, C>
impl<S: Service, C: ServiceEndpoint<S>> RpcServer<S, C>
sourcepub async fn accept(
&self,
) -> Result<(S::Req, RpcChannel<S, C>), RpcServerError<C>>
pub async fn accept( &self, ) -> Result<(S::Req, RpcChannel<S, C>), RpcServerError<C>>
Accepts a new channel from a client, and reads the first request.
The return value is a tuple of (request, channel)
. Here request
is the
first request which is already read from the stream. The channel
is a
RpcChannel that has sink
and stream
fields that can be used to send more
requests and/or receive more responses.
Often sink and stream will wrap an an underlying byte stream. In this case you can call into_inner() on them to get it back to perform byte level reads and writes.
sourcepub fn into_inner(self) -> C
pub fn into_inner(self) -> C
Get the underlying service endpoint