From 44f472c65c72c814499a168b089905792f35e8f2 Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Sat, 27 Feb 2016 22:32:53 -0800 Subject: [PATCH 1/8] Remove unused dep --- tarpc/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/tarpc/Cargo.toml b/tarpc/Cargo.toml index c2453d9..1d038d8 100644 --- a/tarpc/Cargo.toml +++ b/tarpc/Cargo.toml @@ -17,5 +17,4 @@ scoped-pool = "^0.1.5" serde = "^0.6.14" [dev-dependencies] -lazy_static = "^0.1.15" env_logger = "^0.3.2" From 7b5b29a9c31282b9dd15802ec020e25a27fe0991 Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Sat, 2 Apr 2016 15:18:24 -0700 Subject: [PATCH 2/8] Update to serde 0.7 --- tarpc/Cargo.toml | 12 ++++++------ tarpc/src/macros.rs | 9 +++++---- tarpc/src/protocol/mod.rs | 19 +++++++++---------- tarpc/src/protocol/packet.rs | 16 ++++++++-------- tarpc/src/protocol/server.rs | 4 ++-- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tarpc/Cargo.toml b/tarpc/Cargo.toml index c2453d9..43e6235 100644 --- a/tarpc/Cargo.toml +++ b/tarpc/Cargo.toml @@ -11,11 +11,11 @@ readme = "../README.md" description = "An RPC framework for Rust with a focus on ease of use." [dependencies] -bincode = "^0.4.0" -log = "^0.3.5" -scoped-pool = "^0.1.5" -serde = "^0.6.14" +bincode = "^0.5" +log = "^0.3" +scoped-pool = "^0.1" +serde = "^0.7" [dev-dependencies] -lazy_static = "^0.1.15" -env_logger = "^0.3.2" +lazy_static = "^0.1" +env_logger = "^0.3" diff --git a/tarpc/src/macros.rs b/tarpc/src/macros.rs index 02fac66..e4510fa 100644 --- a/tarpc/src/macros.rs +++ b/tarpc/src/macros.rs @@ -110,7 +110,7 @@ macro_rules! impl_serialize { match *self { $( $impler::$name(ref field) => - $crate::macros::serde::Serializer::visit_newtype_variant( + $crate::macros::serde::Serializer::serialize_newtype_variant( serializer, stringify!($impler), $n, @@ -165,11 +165,12 @@ macro_rules! impl_deserialize { } )* return ::std::result::Result::Err( - $crate::macros::serde::de::Error::syntax("expected a field") + $crate::macros::serde::de::Error::custom( + format!("No variants have a value of {}!", value)) ); } } - deserializer.visit_struct_field(__FieldVisitor) + deserializer.deserialize_struct_field(__FieldVisitor) } } @@ -197,7 +198,7 @@ macro_rules! impl_deserialize { stringify!($name) ),* ]; - deserializer.visit_enum(stringify!($impler), VARIANTS, __Visitor) + deserializer.deserialize_enum(stringify!($impler), VARIANTS, __Visitor) } } ); diff --git a/tarpc/src/protocol/mod.rs b/tarpc/src/protocol/mod.rs index 3d9cd44..31dc43e 100644 --- a/tarpc/src/protocol/mod.rs +++ b/tarpc/src/protocol/mod.rs @@ -40,10 +40,13 @@ impl convert::From for Error { impl convert::From for Error { fn from(err: bincode::serde::DeserializeError) -> Error { match err { - bincode::serde::DeserializeError::IoError(ref err) - if err.kind() == io::ErrorKind::ConnectionReset => Error::ConnectionBroken, - bincode::serde::DeserializeError::EndOfStreamError => Error::ConnectionBroken, - bincode::serde::DeserializeError::IoError(err) => Error::Io(Arc::new(err)), + bincode::serde::DeserializeError::IoError(err) => { + match err.kind() { + io::ErrorKind::ConnectionReset | + io::ErrorKind::UnexpectedEof => Error::ConnectionBroken, + _ => Error::Io(Arc::new(err)), + } + } err => panic!("Unexpected error during deserialization: {:?}", err), } } @@ -180,9 +183,7 @@ mod test { let _ = env_logger::init(); let server = Arc::new(Server::new()); let serve_handle = server.spawn_with_config("localhost:0", - Config { - timeout: Some(Duration::new(0, 10)) - }) + Config { timeout: Some(Duration::new(0, 10)) }) .unwrap(); let addr = serve_handle.local_addr().clone(); let client: Client<(), u64> = Client::new(addr).unwrap(); @@ -196,9 +197,7 @@ mod test { let _ = env_logger::init(); let server = Arc::new(Server::new()); let serve_handle = server.spawn_with_config("localhost:0", - Config { - timeout: test_timeout(), - }) + Config { timeout: test_timeout() }) .unwrap(); let addr = serve_handle.local_addr().clone(); let client: Arc> = Arc::new(Client::new(addr).unwrap()); diff --git a/tarpc/src/protocol/packet.rs b/tarpc/src/protocol/packet.rs index 33df794..e0c1caf 100644 --- a/tarpc/src/protocol/packet.rs +++ b/tarpc/src/protocol/packet.rs @@ -19,11 +19,11 @@ impl Serialize for Packet { fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer { - serializer.visit_struct(PACKET, - MapVisitor { - value: self, - state: 0, - }) + serializer.serialize_struct(PACKET, + MapVisitor { + value: self, + state: 0, + }) } } @@ -40,11 +40,11 @@ impl<'a, T: Serialize> ser::MapVisitor for MapVisitor<'a, T> { match self.state { 0 => { self.state += 1; - Ok(Some(try!(serializer.visit_struct_elt(RPC_ID, &self.value.rpc_id)))) + Ok(Some(try!(serializer.serialize_struct_elt(RPC_ID, &self.value.rpc_id)))) } 1 => { self.state += 1; - Ok(Some(try!(serializer.visit_struct_elt(MESSAGE, &self.value.message)))) + Ok(Some(try!(serializer.serialize_struct_elt(MESSAGE, &self.value.message)))) } _ => Ok(None), } @@ -62,7 +62,7 @@ impl Deserialize for Packet { where D: Deserializer { const FIELDS: &'static [&'static str] = &[RPC_ID, MESSAGE]; - deserializer.visit_struct(PACKET, FIELDS, Visitor(PhantomData)) + deserializer.deserialize_struct(PACKET, FIELDS, Visitor(PhantomData)) } } diff --git a/tarpc/src/protocol/server.rs b/tarpc/src/protocol/server.rs index 0631712..69149d0 100644 --- a/tarpc/src/protocol/server.rs +++ b/tarpc/src/protocol/server.rs @@ -214,7 +214,7 @@ pub trait Serve: Send + Sync + Sized { /// spawn fn spawn(self, addr: A) -> io::Result where A: ToSocketAddrs, - Self: 'static, + Self: 'static { self.spawn_with_config(addr, Config::default()) } @@ -222,7 +222,7 @@ pub trait Serve: Send + Sync + Sized { /// spawn fn spawn_with_config(self, addr: A, config: Config) -> io::Result where A: ToSocketAddrs, - Self: 'static, + Self: 'static { let listener = try!(TcpListener::bind(&addr)); let addr = try!(listener.local_addr()); From 9235e12904eda411ffc39d9ed6d7d4d92afbe1b3 Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Sat, 2 Apr 2016 15:33:56 -0700 Subject: [PATCH 3/8] Handle Serde(EndOfStream) error as ConnectionBroken --- tarpc/src/protocol/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tarpc/src/protocol/mod.rs b/tarpc/src/protocol/mod.rs index 31dc43e..c7e2132 100644 --- a/tarpc/src/protocol/mod.rs +++ b/tarpc/src/protocol/mod.rs @@ -6,6 +6,7 @@ use bincode::{self, SizeLimit}; use bincode::serde::{deserialize_from, serialize_into}; use serde; +use serde::de::value::Error::EndOfStream; use std::io::{self, Read, Write}; use std::convert; use std::sync::Arc; @@ -40,6 +41,7 @@ impl convert::From for Error { impl convert::From for Error { fn from(err: bincode::serde::DeserializeError) -> Error { match err { + bincode::serde::DeserializeError::Serde(EndOfStream) => Error::ConnectionBroken, bincode::serde::DeserializeError::IoError(err) => { match err.kind() { io::ErrorKind::ConnectionReset | From 32e0b0d7f83b9c54df1aaf8aa942a73f4b7f5b29 Mon Sep 17 00:00:00 2001 From: shaladdle Date: Sat, 2 Apr 2016 16:56:20 -0700 Subject: [PATCH 4/8] Bump version to 0.4.0 --- tarpc/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tarpc/Cargo.toml b/tarpc/Cargo.toml index 43e6235..9208725 100644 --- a/tarpc/Cargo.toml +++ b/tarpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tarpc" -version = "0.3.0" +version = "0.4.0" authors = ["Adam Wright ", "Tim Kuehn "] license = "MIT" documentation = "https://google.github.io/tarpc" From 9dafc704e9dd87abe5d3f93fbcb442b3c9f520d9 Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Sun, 24 Apr 2016 17:19:53 -0700 Subject: [PATCH 5/8] Update RELEASES.md --- RELEASES.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 0fcffb0..b4fdad6 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,4 +1,11 @@ -## 1.3 (2016-02-20) +## 0.4 (2016-04-02) + +### Breaking Changes +* Updated to the latest version of serde. Because tarpc exposes serde in + its API, this forces downstream code to update to the latest version of + serde, as well. + +## 0.3 (2016-02-20) ### Breaking Changes * The timeout arg to `serve` was replaced with a `Config` struct, which From 1cc8cbcdc3b1970ddb97b2b7bab3ab7481494b08 Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Sun, 24 Apr 2016 17:48:29 -0700 Subject: [PATCH 6/8] Update pre-push to use rustup in lieu of multirust, because rustup is #thefuture. --- hooks/pre-push | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hooks/pre-push b/hooks/pre-push index 2a63b79..b57b17b 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -8,7 +8,7 @@ # Pre-push hook for the tarpc repository. To use this hook, copy it to .git/hooks in your repository # root. # -# This hook runs tests to make sure only working code is being pushed. If present, multirust is used +# This hook runs tests to make sure only working code is being pushed. If present, rustup is used # to build and test the code on the appropriate toolchains. The working copy must not contain # uncommitted changes, since the script currently just runs cargo build/test in the working copy. # @@ -67,7 +67,7 @@ run_cargo() { fi if [ "$3" != "" ]; then printf "${PREFIX} $VERB $2 on $3 ... " - multirust run $3 cargo $1 --manifest-path $2/Cargo.toml &>/dev/null + rustup run $3 cargo $1 --manifest-path $2/Cargo.toml &>/dev/null else printf "${PREFIX} $VERB $2 ... " cargo $1 --manifest-path $2/Cargo.toml &>/dev/null @@ -83,7 +83,7 @@ run_cargo() { TOOLCHAIN_RESULT=0 check_toolchain() { printf "${PREFIX} Checking for $1 toolchain ... " - if [[ $(multirust list-toolchain) =~ $1 ]]; then + if [[ $(rustup toolchain list) =~ $1 ]]; then printf "${SUCCESS}\n" else TOOLCHAIN_RESULT=1 @@ -92,8 +92,8 @@ check_toolchain() { fi } -printf "${PREFIX} Checking for multirust ... " -command -v multirust &>/dev/null +printf "${PREFIX} Checking for rustup ... " +command -v rustup &>/dev/null if [ "$?" == 0 ] && [ "${TARPC_USE_CURRENT_TOOLCHAIN}" == "" ]; then printf "${SUCCESS}\n" From 166f1523d6c1c27d735f7fec9a4d5a850a52654b Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Sun, 24 Apr 2016 17:52:08 -0700 Subject: [PATCH 7/8] Update version in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 68d6f3a..c146188 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ function then returns the value produced by that other server. Add to your `Cargo.toml` dependencies: ```toml -tarpc = "0.3.0" +tarpc = "0.4.0" ``` ## Example From 43a2df4a13111fb2ba28cb9afa1b1ecda61f8504 Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 24 Apr 2016 17:56:41 -0700 Subject: [PATCH 8/8] Make version of serde explicit in release notes --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index b4fdad6..f42ec98 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,7 +1,7 @@ ## 0.4 (2016-04-02) ### Breaking Changes -* Updated to the latest version of serde. Because tarpc exposes serde in +* Updated to the latest version of serde, 0.7.0. Because tarpc exposes serde in its API, this forces downstream code to update to the latest version of serde, as well.