// Copyright 2016 Google Inc. All Rights Reserved. // // Licensed under the MIT License, . // This file may not be copied, modified, or distributed except according to those terms. #![feature(conservative_impl_trait, plugin)] #![plugin(tarpc_plugins)] extern crate futures; #[macro_use] extern crate tarpc; use futures::Future; use tarpc::util::{FirstSocketAddr, Never}; use tarpc::sync::Connect; service! { rpc hello(name: String) -> String; } #[derive(Clone)] struct HelloServer; impl FutureService for HelloServer { type HelloFut = futures::Finished; fn hello(&self, name: String) -> Self::HelloFut { futures::finished(format!("Hello, {}!", name)) } } fn main() { let addr = HelloServer.listen("localhost:10000".first_socket_addr()).wait().unwrap(); let client = SyncClient::connect(addr).unwrap(); println!("{}", client.hello("Mom".to_string()).unwrap()); }