Struct Builder

Source
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 Builder<(), ()>

Source

pub fn new(interface: Interface) -> Self

Create a new builder from an Interface

Source§

impl<C> Builder<C, ()>

Source

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>

Source

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.

Source§

impl<C> Builder<C, ()>
where C: Client + From<Configuration<C::Request, C::Response>> + 'static, <C as Client>::Response: DeserializeOwned, <C as Client>::Request: Serialize,

Source

pub fn build(self) -> C

Build function for client-only RPC interfaces.

Source§

impl<S> Builder<(), S>
where S: Service + 'static, <S as Service>::Request: DeserializeOwned, <S as Service>::Response: Serialize,

Source

pub fn build(self) -> Server

Build function for server-only RPC interfaces.

Source§

impl<C, S> Builder<C, S>
where C: Client + From<Configuration<C::Request, C::Response>> + 'static, S: Service + 'static, <S as Service>::Request: DeserializeOwned, <S as Service>::Response: Serialize, <C as Client>::Request: Serialize, <C as Client>::Response: DeserializeOwned,

Source

pub fn build(self) -> (C, Server)

Build function for client-server RPC interfaces.

Auto Trait Implementations§

§

impl<C, S> Freeze for Builder<C, S>
where S: Freeze,

§

impl<C, S> !RefUnwindSafe for Builder<C, S>

§

impl<C, S> !Send for Builder<C, S>

§

impl<C, S> !Sync for Builder<C, S>

§

impl<C, S> Unpin for Builder<C, S>
where S: Unpin, C: Unpin,

§

impl<C, S> !UnwindSafe for Builder<C, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.