Trait merfolk::interfaces::Backend[][src]

pub trait Backend: Send {
    type Intermediate: Serialize + for<'a> Deserialize<'a>;
    fn register<T>(&mut self, receiver: T) -> Result<()>
    where
        T: Fn(Call<Self::Intermediate>) -> Result<Reply<Self::Intermediate>> + Send + Sync + 'static
;
fn call(
        &mut self,
        call: Call<Self::Intermediate>
    ) -> Result<Reply<Self::Intermediate>>;
fn serialize<T: Serialize>(from: &T) -> Result<Self::Intermediate>;
fn deserialize<T>(from: &Self::Intermediate) -> Result<T>
    where
        T: for<'de> Deserialize<'de>
; }

The Backend is responsible for sending and receiving RPCs. The Backend serializes and deserializes the packages and sends and reveices them over a chsen channel.

Incomming RPCs

The Backend is acting as server.

Incomming calls from the client are passed on to the Frontend as Call<Intermediate>. The Reply<Intermediate>s from the Frontend are sent back to the client.

Outgoing RPCs

The Backend is acting as client.

The Frontend passes Call<Intermediate>s to the Backend which sends them to the server. The replies are received from the server and passed on to the Frontend as Reply<Intermediate>s.

Examples

For examples look at the provided Backends:

Associated Types

type Intermediate: Serialize + for<'a> Deserialize<'a>[src]

The Intermediate type required by the Backend.

Loading content...

Required methods

fn register<T>(&mut self, receiver: T) -> Result<()> where
    T: Fn(Call<Self::Intermediate>) -> Result<Reply<Self::Intermediate>> + Send + Sync + 'static, 
[src]

Registers the server callback function from Mer. The callback is used to pass incomming Calls to the Frontend.

fn call(
    &mut self,
    call: Call<Self::Intermediate>
) -> Result<Reply<Self::Intermediate>>
[src]

This function is called by the Frontend for outgoing Calls.

fn serialize<T: Serialize>(from: &T) -> Result<Self::Intermediate>[src]

Serializes a type T to the Intermediate type.

fn deserialize<T>(from: &Self::Intermediate) -> Result<T> where
    T: for<'de> Deserialize<'de>, 
[src]

Deserializes the Intermediate type to a type T.

Loading content...

Implementors

Loading content...