pub struct Builder<C, S> { /* private fields */ }
Expand description
This struct allows one to configure the RPC interface prior to creating it.
To get an instance of this struct, call Builder<C, S>::new
with
an Interface
.
Implementations§
Source§impl<C> Builder<C, ()>
impl<C> Builder<C, ()>
Sourcepub fn with_service<S: Service>(
self,
implementation: impl Into<S>,
) -> Builder<C, S>
pub fn with_service<S: Service>( self, implementation: impl Into<S>, ) -> Builder<C, S>
Configure the RPC interface with a service that implements methods
that can be called from the other side of the channel. To use this method,
you need to specify the type S
which is the service type generated by the
attribute macro service
. The implementation parameter is then an
instance of something that implements the trait to which to applied the
service
macro. For example, if you have a trait Calculator
to
which you have applied service
, you would use this method as follows:
struct CalculatorServiceImpl;
impl Calculator for CalculatorServiceImpl { /* add Calculator's methods */}
let server = Builder::new(some_interface)
.with_service<CalculatorService<_>>(CalculatorServiceImpl)
.build();
Source§impl<S> Builder<(), S>
impl<S> Builder<(), S>
Sourcepub fn with_client<C: Client>(self) -> Builder<C, S>
pub fn with_client<C: Client>(self) -> Builder<C, S>
Configure the RPC interface with a client that allows you to execute RPCs on the
server. The builder will automatically instansiate the client for you, you just
need to provide the type which is generated via the service
attribute
macro. For example, if you had a trait Calculator
to which you applied the
service
attribute macro, the macro would have generated a CalculatorClient
struct which you can use as the C
in this function.