#[macro_use] extern crate flugrost; use std::net::TcpStream; use std::env; use flugrost::FlugrostProtocol; mod svc { rpc_service!{ rpc greet(s: String) -> String; rpc add(n1: u32, n2: u32) -> u64; rpc sub(n1: u32, n2: u32) -> i64; } } fn main() { let args: Vec<_> = env::args().collect(); if args.len() != 3 { println!("Usage: {} ip port", args[0]); return; } let host = format!("{}:{}", args[1], args[2]); let socket = TcpStream::connect(host).expect("connect() failed!"); let proto = FlugrostProtocol::new(); let mut client = svc::SyncClient::from_blocking_socket(&socket, &proto); println!( "Server says: {}", client.greet("Hi".to_owned()).expect("RPC call failed!") ); println!("1 + 2 = {}", client.add(1, 2).expect("RPC call failed")); println!("1 - 2 = {}", client.sub(1, 2).expect("RPC call failed")); }