extern crate flugrost; use std::env; use std::net::TcpStream; use flugrost::FlugrostProtocol; use flugrost::connection::Connection; use flugrost::connection::FetchResult; use flugrost::tracker::RequestTracker; 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).unwrap(); let proto = FlugrostProtocol::new(); let mut conn = Connection::from_blocking_socket(&socket, &proto); let mut tracker = RequestTracker::new(); { let req = tracker .create_request_msg("add".to_owned(), &(1, 2), ()) .unwrap(); conn.send(&req).unwrap(); conn.notify_writable().unwrap(); for fr in conn.fetch() { match fr.unwrap() { FetchResult::EOF => return, FetchResult::Message(m) => { let res = m.unwrap_response(); let res: u32 = tracker.handle_response(res).unwrap().1; println!("Result of 1+2 is {}", res); } } } } }