Crate tarpc [] [src]

An RPC library for Rust.

Example usage:

#[macro_use] extern crate tarpc;
mod my_server {
    service! {
        rpc hello(name: String) -> String;
        rpc add(x: i32, y: i32) -> i32;
    }
}

use self::my_server::*;
use std::time::Duration;

struct Server;
impl my_server::Service for Server {
    fn hello(&self, s: String) -> String {
        format!("Hello, {}!", s)
    }
    fn add(&self, x: i32, y: i32) -> i32 {
        x + y
    }
}

fn main() {
    let addr = "127.0.0.1:9000";
    let shutdown = Server.spawn(addr).unwrap();
    let client = Client::new(addr).unwrap();
    assert_eq!(3, client.add(1, 2).unwrap());
    assert_eq!("Hello, Mom!".to_string(),
               client.hello("Mom".to_string()).unwrap());
    drop(client);
    shutdown.shutdown();
}

Reexports

pub use protocol::{Config, Error, Result};

Modules

macros

Provides the macro used for constructing rpc services and client stubs.

protocol

Provides the tarpc client and server, which implements the tarpc protocol. The protocol is defined by the implementation.

Macros

service!

The main macro that creates RPC services.

Structs

ServeHandle

Provides methods for blocking until the server completes,