diff --git a/src/macros/src/main.rs b/src/macros/src/main.rs index ebc1086..f2b884d 100644 --- a/src/macros/src/main.rs +++ b/src/macros/src/main.rs @@ -5,16 +5,21 @@ extern crate byteorder; use std::net::{TcpListener, TcpStream}; +#[derive(Debug, RustcEncodable, RustcDecodable)] +pub struct Foo { + message: String +} + rpc_service!(my_server: - hello(String) -> String; + hello(::Foo) -> ::Foo; add((i32, i32)) -> i32; ); use my_server::*; impl Service for () { - fn hello(&self, s: String) -> String { - format!("Hello, {}", s) + fn hello(&self, s: Foo) -> Foo { + Foo{message: format!("Hello, {}", &s.message)} } fn add(&self, (x, y): (i32, i32)) -> i32 { @@ -33,5 +38,5 @@ fn main() { let mut client = Client(TcpStream::connect("127.0.0.1:9000").unwrap()); println!("Client running"); println!("add((1, 2)) => {}", client.add((1, 2)).unwrap()); - println!("hello(\"adam\") => {:?}", client.hello("Adam".into())); + println!("hello(\"adam\") => {:?}", client.hello(Foo{message: "Adam".into()})); }