15 Commits

Author SHA1 Message Date
shaladdle
32e0b0d7f8 Bump version to 0.4.0 2016-04-02 16:56:20 -07:00
shaladdle
b87c52758e Merge pull request #30 from tikue/update-serde
Update serde to 0.7
2016-04-02 15:57:18 -07:00
Tim Kuehn
9235e12904 Handle Serde(EndOfStream) error as ConnectionBroken 2016-04-02 15:33:56 -07:00
Tim Kuehn
265fe56fa6 Merge update-serde into master 2016-04-02 15:23:37 -07:00
Tim Kuehn
7b5b29a9c3 Update to serde 0.7 2016-04-02 15:18:24 -07:00
shaladdle
fe978f2c56 Merge pull request #29 from tikue/rm-lazy-static
Remove unused dep
2016-03-02 21:36:24 -08:00
Tim Kuehn
44f472c65c Remove unused dep 2016-02-27 22:32:53 -08:00
Tim Kuehn
e8fcf0e4de Fix issue with grep exit status 2016-02-27 02:30:39 -08:00
shaladdle
2eb0b2cc83 Merge pull request #28 from tikue/fix-pre-commit
Fix formatting pre-commit check
2016-02-25 23:24:18 -08:00
Tim Kuehn
a8766a9200 Use rustfmt --write-mode=diff in lieu of hashes 2016-02-25 00:50:46 -08:00
Tim Kuehn
ef96c87226 Skip children when rustfmting in pre-commit 2016-02-25 00:50:37 -08:00
Tim Kuehn
3543b34f2b Fix formatting check.
* shasum suffixes the checksum with '- filename' so pipe in the text instead.
* rustfmt prefixes the formatting with 'Using rustfmt config file filename' so pipe in the text instead.
2016-02-25 00:50:29 -08:00
Tim
4c1d15f8ea Merge pull request #26 from Bowbaq/master
Fix your typo
2016-02-20 18:50:25 -08:00
Maxime Bury
ece1cc60b9 Fix your typo 2016-02-20 18:43:31 -08:00
shaladdle
7d8a508379 Merge pull request #25 from tikue/fix-readme
Fix the README example. It broke again. :(
2016-02-20 01:33:29 -08:00
7 changed files with 37 additions and 35 deletions

View File

@@ -68,7 +68,7 @@ items expanded by a `service!` invocation.
## Additional Features
- Concurrent requests from a single client.
- Any type that `impl`s `serde`'s Serialize` and `Deserialize` can be used in the rpc signatures.
- Any type that `impl`s `serde`'s `Serialize` and `Deserialize` can be used in the rpc signatures.
- Attributes can be specified on rpc methods. These will be included on both the `Service` trait
methods as well as on the `Client`'s stub methods.
- Just like regular fns, the return type can be left off when it's `-> ()`.

View File

@@ -92,9 +92,8 @@ FMTRESULT=0
for file in $(git diff --name-only --cached);
do
if [ ${file: -3} == ".rs" ]; then
HASH=$(shasum $file)
NEW_HASH=$(rustfmt --write-mode=display $file | shasum)
if [ "${HASH}" != "${NEW_HASH}" ]; then
diff=$(rustfmt --skip-children --write-mode=diff $file)
if grep --quiet "^Diff at line" <<< "$diff"; then
FMTRESULT=1
fi
fi
@@ -105,6 +104,7 @@ if [ "${TARPC_SKIP_RUSTFMT}" == 1 ]; then
elif [ ${FMTRESULT} != 0 ]; then
FAILED=1
printf "${FAILURE}\n"
echo "$diff" | sed '/Using rustfmt.*$/d'
else
printf "${SUCCESS}\n"
fi

View File

@@ -1,6 +1,6 @@
[package]
name = "tarpc"
version = "0.3.0"
version = "0.4.0"
authors = ["Adam Wright <adam.austin.wright@gmail.com>", "Tim Kuehn <timothy.j.kuehn@gmail.com>"]
license = "MIT"
documentation = "https://google.github.io/tarpc"
@@ -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"

View File

@@ -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)
}
}
);

View File

@@ -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,10 +41,14 @@ impl convert::From<bincode::serde::SerializeError> for Error {
impl convert::From<bincode::serde::DeserializeError> 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::Serde(EndOfStream) => Error::ConnectionBroken,
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 +185,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 +199,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<Client<(), u64>> = Arc::new(Client::new(addr).unwrap());

View File

@@ -19,11 +19,11 @@ impl<T: Serialize> Serialize for Packet<T> {
fn serialize<S>(&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<T: Deserialize> Deserialize for Packet<T> {
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))
}
}

View File

@@ -214,7 +214,7 @@ pub trait Serve: Send + Sync + Sized {
/// spawn
fn spawn<A>(self, addr: A) -> io::Result<ServeHandle>
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<A>(self, addr: A, config: Config) -> io::Result<ServeHandle>
where A: ToSocketAddrs,
Self: 'static,
Self: 'static
{
let listener = try!(TcpListener::bind(&addr));
let addr = try!(listener.local_addr());