diff --git a/README.md b/README.md index b8b3e75..3c7c5af 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ tarpc-plugins = { git = "https://github.com/google/tarpc" } ## Example ```rust -// required by `FutureClient` (not used in this example) +// required by `FutureClient` (not used directly in this example) #![feature(conservative_impl_trait, plugin)] #![plugin(tarpc_plugins)] @@ -51,8 +51,8 @@ extern crate futures; #[macro_use] extern crate tarpc; +use tarpc::client::sync::Connect; use tarpc::util::Never; -use tarpc::sync::Connect; service! { rpc hello(name: String) -> String; @@ -62,7 +62,7 @@ service! { struct HelloServer; impl SyncService for HelloServer { - fn hello(&mut self, name: String) -> Result { + fn hello(&self, name: String) -> Result { Ok(format!("Hello, {}!", name)) } } @@ -99,7 +99,7 @@ extern crate tarpc; extern crate tokio_core; use futures::Future; -use tarpc::future::Connect; +use tarpc::client::future::{Connect, Options}; use tarpc::util::{FirstSocketAddr, Never}; use tokio_core::reactor; @@ -113,7 +113,7 @@ struct HelloServer; impl FutureService for HelloServer { type HelloFut = futures::Finished; - fn hello(&mut self, name: String) -> Self::HelloFut { + fn hello(&self, name: String) -> Self::HelloFut { futures::finished(format!("Hello, {}!", name)) } } @@ -122,12 +122,12 @@ fn main() { let addr = "localhost:10000".first_socket_addr(); let mut core = reactor::Core::new().unwrap(); HelloServer.listen_with(addr, core.handle()).unwrap(); - core.run( - FutureClient::connect(&addr) + let options = Options::default().handle(core.handle()); + core.run(FutureClient::connect(addr, options) .map_err(tarpc::Error::from) - .and_then(|mut client| client.hello("Mom".to_string())) - .map(|resp| println!("{}", resp)) - ).unwrap(); + .and_then(|client| client.hello("Mom".to_string())) + .map(|resp| println!("{}", resp))) + .unwrap(); } ``` diff --git a/examples/readme_futures.rs b/examples/readme_futures.rs index e8a04f3..c538416 100644 --- a/examples/readme_futures.rs +++ b/examples/readme_futures.rs @@ -34,9 +34,9 @@ impl FutureService for HelloServer { fn main() { let addr = "localhost:10000".first_socket_addr(); let mut core = reactor::Core::new().unwrap(); - let handle = core.handle(); HelloServer.listen_with(addr, core.handle()).unwrap(); - core.run(FutureClient::connect(addr, Options::default().handle(handle)) + let options = Options::default().handle(core.handle()); + core.run(FutureClient::connect(addr, options) .map_err(tarpc::Error::from) .and_then(|client| client.hello("Mom".to_string())) .map(|resp| println!("{}", resp)))