Function ya_service_bus::typed::bind[][src]

pub fn bind<T: RpcMessage>(
    addr: &str,
    endpoint: impl RpcHandler<T> + Unpin + 'static
) -> Handle
Expand description

Binds RpcHandler to given service address.

Example

use ya_service_bus::{typed as bus, RpcMessage};
use serde::{Serialize, Deserialize};
use actix::System;

#[derive(Serialize, Deserialize)]
struct Echo(String);

impl RpcMessage for Echo {
    const ID :&'static str = "echo";
    type Item = String;
    type Error=();
}

fn main() {
     let sys = System::new("test");
     let _ = bus::bind("/local/echo", |e:Echo| {
         async {
            Ok(e.0)
         }
     });
 }