Frontend

Trait Frontend 

Source
pub trait Frontend: Send {
    type Backend: Backend;

    // Required methods
    fn register<T>(&mut self, caller: T) -> Result<()>
       where T: Fn(Call<<Self::Backend as Backend>::Intermediate>) -> Result<Reply<<Self::Backend as Backend>::Intermediate>> + Send + Sync + 'static;
    fn receive(
        &self,
        call: Call<<Self::Backend as Backend>::Intermediate>,
    ) -> Result<Reply<<Self::Backend as Backend>::Intermediate>>;
}
Expand description

The Frontend is responsible for processing incomming RPCs and for passing on outgoing RPCs to the Backend. The Frontend provides a way to make calls on the client side and a way to register procedures on the server side.

§Incomming RPCs

The Frontend is acting as server.

Incomming Call<Intermediate>s are received from the Backend. The calls are deserialized via Backend::deserialize to the correct type. The calls are processed and the replys serialized via Backend::serialize and passed on to the Backend as Reply<Intermediate>.

§Outgoing RPCs

The Frontend is acting as client.

The Frontend serializes the calls via Backend::serialize and passes them to the Backend as Call<Intermediate>. The replies are received from the Backend deserialized via Backend::deserialize passed on as response.

§Examples

For examples look at the provided Frontends:

Required Associated Types§

Source

type Backend: Backend

The used Backend.

Required Methods§

Source

fn register<T>(&mut self, caller: T) -> Result<()>
where T: Fn(Call<<Self::Backend as Backend>::Intermediate>) -> Result<Reply<<Self::Backend as Backend>::Intermediate>> + Send + Sync + 'static,

Registers the client callback function from Mer. The callback is used to pass outgoing Calls to the Backend.

Source

fn receive( &self, call: Call<<Self::Backend as Backend>::Intermediate>, ) -> Result<Reply<<Self::Backend as Backend>::Intermediate>>

This function is called by the Backend for incomming Calls.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§