5 Commits

Author SHA1 Message Date
Tim
9bd66b7e49 Bump version (#195) 2018-08-13 15:49:17 -07:00
Yechan Bae
0ecc7a80c1 Do not ignore payload size in sync client (#194) 2018-08-12 10:39:20 -07:00
Tim
92f157206d Minor change rollup
* Head off imminent breakage due to https://github.com/rust-lang/rust/pull/51285.
* Fix examples and documentation to use a recently-gated feature, `proc_macro_path_invoc`.
* Update dependency versions.
2018-07-11 17:04:54 -07:00
Tim
b093db63a3 Remove usage of Cursor (#186)
* Add intellij files to .gitignore

* Remove Cursor usage when deserializing

* Don't use methods that copy into another temp buffer
2018-04-14 21:16:35 -07:00
Tim
8c3e3df47f Bump tarpc-plugins version. (#185) 2018-04-09 18:45:28 -07:00
19 changed files with 44 additions and 41 deletions

2
.gitignore vendored
View File

@@ -3,3 +3,5 @@ Cargo.lock
.cargo
*.swp
*.bk
tarpc.iml
.idea

View File

@@ -1,6 +1,6 @@
[package]
name = "tarpc"
version = "0.11.0"
version = "0.12.1"
authors = ["Adam Wright <adam.austin.wright@gmail.com>", "Tim Kuehn <timothy.j.kuehn@gmail.com>"]
license = "MIT"
documentation = "https://docs.rs/tarpc"
@@ -26,15 +26,16 @@ net2 = "0.2"
num_cpus = "1.0"
serde = "1.0"
serde_derive = "1.0"
tarpc-plugins = { path = "src/plugins", version = "0.2.0" }
tarpc-plugins = { path = "src/plugins", version = "0.4.0" }
thread-pool = "0.1.1"
tokio-codec = "0.1"
tokio-core = "0.1.6"
tokio-io = "0.1"
tokio-proto = "0.1.1"
tokio-service = "0.1"
# Optional dependencies
native-tls = { version = "0.1.1", optional = true }
native-tls = { version = "0.1", optional = true }
tokio-tls = { version = "0.1", optional = true }
[dev-dependencies]

View File

@@ -37,8 +37,8 @@ arguments to tarpc fns.
Add to your `Cargo.toml` dependencies:
```toml
tarpc = "0.11.0"
tarpc-plugins = "0.2.0"
tarpc = "0.12.0"
tarpc-plugins = "0.4.0"
```
## Example: Sync
@@ -47,7 +47,7 @@ tarpc has two APIs: `sync` for blocking code and `future` for asynchronous
code. Here's how to use the sync api.
```rust
#![feature(plugin, use_extern_macros)]
#![feature(plugin, use_extern_macros, proc_macro_path_invoc)]
#![plugin(tarpc_plugins)]
#[macro_use]
@@ -100,7 +100,7 @@ races! See the `tarpc_examples` package for more examples.
Here's the same service, implemented using futures.
```rust
#![feature(plugin, use_extern_macros)]
#![feature(plugin, use_extern_macros, proc_macro_path_invoc)]
#![plugin(tarpc_plugins)]
extern crate futures;
@@ -171,7 +171,7 @@ However, if you are working with both stream types, ensure that you use the TLS
servers and TCP clients with TCP servers.
```rust,no_run
#![feature(plugin, use_extern_macros)]
#![feature(plugin, use_extern_macros, proc_macro_path_invoc)]
#![plugin(tarpc_plugins)]
extern crate futures;

View File

@@ -3,7 +3,7 @@
// Licensed under the MIT License, <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
#![feature(plugin, test, use_extern_macros)]
#![feature(plugin, test, use_extern_macros, proc_macro_path_invoc)]
#![plugin(tarpc_plugins)]
#[macro_use]

View File

@@ -3,7 +3,7 @@
// Licensed under the MIT License, <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
#![feature(plugin, never_type, use_extern_macros)]
#![feature(plugin, never_type, use_extern_macros, proc_macro_path_invoc)]
#![plugin(tarpc_plugins)]
extern crate chrono;

View File

@@ -3,7 +3,7 @@
// Licensed under the MIT License, <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
#![feature(plugin, use_extern_macros)]
#![feature(plugin, use_extern_macros, proc_macro_path_invoc)]
#![plugin(tarpc_plugins)]
extern crate env_logger;

View File

@@ -3,7 +3,7 @@
// Licensed under the MIT License, <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
#![feature(plugin, use_extern_macros)]
#![feature(plugin, use_extern_macros, proc_macro_path_invoc)]
#![plugin(tarpc_plugins)]
#[macro_use]

View File

@@ -3,7 +3,7 @@
// Licensed under the MIT License, <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
#![feature(plugin, use_extern_macros)]
#![feature(plugin, use_extern_macros, proc_macro_path_invoc)]
#![plugin(tarpc_plugins)]
extern crate futures;

View File

@@ -4,7 +4,7 @@
// This file may not be copied, modified, or distributed except according to those terms.
// required by `FutureClient` (not used directly in this example)
#![feature(plugin, use_extern_macros)]
#![feature(plugin, use_extern_macros, proc_macro_path_invoc)]
#![plugin(tarpc_plugins)]
#[macro_use]

View File

@@ -3,7 +3,7 @@
// Licensed under the MIT License, <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
#![feature(plugin, use_extern_macros)]
#![feature(plugin, use_extern_macros, proc_macro_path_invoc)]
#![plugin(tarpc_plugins)]
extern crate env_logger;

View File

@@ -3,7 +3,7 @@
// Licensed under the MIT License, <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
#![feature(plugin, use_extern_macros)]
#![feature(plugin, use_extern_macros, proc_macro_path_invoc)]
#![plugin(tarpc_plugins)]
extern crate env_logger;

View File

@@ -3,7 +3,7 @@
// Licensed under the MIT License, <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
#![feature(plugin, use_extern_macros)]
#![feature(plugin, use_extern_macros, proc_macro_path_invoc)]
#![plugin(tarpc_plugins)]
#[macro_use]

View File

@@ -3,7 +3,7 @@
// Licensed under the MIT License, <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
#![feature(plugin, use_extern_macros)]
#![feature(plugin, use_extern_macros, proc_macro_path_invoc)]
#![plugin(tarpc_plugins)]
#[macro_use]

View File

@@ -27,7 +27,7 @@
//! Example usage:
//!
//! ```
//! #![feature(plugin, use_extern_macros)]
//! #![feature(plugin, use_extern_macros, proc_macro_path_invoc)]
//! #![plugin(tarpc_plugins)]
//!
//! #[macro_use]
@@ -71,7 +71,7 @@
//! Example usage with TLS:
//!
//! ```no-run
//! #![feature(plugin, use_extern_macros)]
//! #![feature(plugin, use_extern_macros, proc_macro_path_invoc)]
//! #![plugin(tarpc_plugins)]
//!
//! #[macro_use]
@@ -116,7 +116,7 @@
#![deny(missing_docs, missing_debug_implementations)]
#![feature(never_type)]
#![cfg_attr(test, feature(plugin, use_extern_macros))]
#![cfg_attr(test, feature(plugin, use_extern_macros, proc_macro_path_invoc))]
#![cfg_attr(test, plugin(tarpc_plugins))]
extern crate byteorder;
@@ -130,6 +130,7 @@ extern crate log;
extern crate net2;
extern crate num_cpus;
extern crate thread_pool;
extern crate tokio_codec;
extern crate tokio_io;
#[doc(hidden)]

View File

@@ -14,7 +14,7 @@ macro_rules! as_item {
/// Rpc methods are specified, mirroring trait syntax:
///
/// ```
/// # #![feature(plugin, use_extern_macros)]
/// # #![feature(plugin, use_extern_macros, proc_macro_path_invoc)]
/// # #![plugin(tarpc_plugins)]
/// # #[macro_use] extern crate tarpc;
/// # fn main() {}
@@ -657,7 +657,6 @@ mod functional_test {
fn get_tls_client_context() -> Context {
let mut connector = unwrap!(TlsConnector::builder());
unwrap!(connector.builder_mut()
.builder_mut()
.set_ca_file("test/root-ca.pem"));
Context {
domain: DOMAIN.into(),

View File

@@ -1,6 +1,6 @@
[package]
name = "tarpc-plugins"
version = "0.2.0"
version = "0.4.0"
authors = ["Adam Wright <adam.austin.wright@gmail.com>", "Tim Kuehn <timothy.j.kuehn@gmail.com>"]
license = "MIT"
documentation = "https://docs.rs/tarpc"

View File

@@ -8,7 +8,7 @@ use itertools::Itertools;
use rustc_plugin::Registry;
use syntax::ast::{self, Ident, TraitRef, Ty, TyKind};
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
use syntax::ext::quote::rt::Span;
use syntax::codemap::Span;
use syntax::parse::{self, token, str_lit, PResult};
use syntax::parse::parser::{Parser, PathStyle};
use syntax::symbol::Symbol;

View File

@@ -4,15 +4,15 @@
// This file may not be copied, modified, or distributed except according to those terms.
use bincode;
use byteorder::{BigEndian, ReadBytesExt};
use byteorder::{BigEndian, ByteOrder};
use bytes::BytesMut;
use bytes::buf::BufMut;
use serde;
use std::io::{self, Cursor};
use std::io;
use std::marker::PhantomData;
use std::mem;
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_io::codec::{Encoder, Decoder, Framed};
use tokio_codec::{Encoder, Decoder, Framed};
use tokio_proto::multiplex::{ClientProto, ServerProto};
use tokio_proto::streaming::multiplex::RequestId;
@@ -34,7 +34,7 @@ enum CodecState {
impl<Encode, Decode> Codec<Encode, Decode> {
fn new(max_payload_size: u64) -> Self {
Codec {
max_payload_size: max_payload_size,
max_payload_size,
state: CodecState::Id,
_phantom_data: PhantomData,
}
@@ -74,9 +74,9 @@ where
}
let message_size = 2 * mem::size_of::<u64>() + payload_size as usize;
buf.reserve(message_size);
buf.put_u64::<BigEndian>(id);
buf.put_u64_be(id);
trace!("Encoded request id = {} as {:?}", id, buf);
buf.put_u64::<BigEndian>(payload_size);
buf.put_u64_be(payload_size);
bincode::serialize_into(&mut buf.writer(), &message)
.map_err(|serialize_err| {
io::Error::new(io::ErrorKind::Other, serialize_err)
@@ -105,9 +105,9 @@ where
}
Id => {
let mut id_buf = buf.split_to(mem::size_of::<u64>());
let id = Cursor::new(&mut id_buf).read_u64::<BigEndian>()?;
let id = BigEndian::read_u64(&*id_buf);
trace!("--> Parsed id = {} from {:?}", id, id_buf);
self.state = Len { id: id };
self.state = Len { id };
}
Len { .. } if buf.len() < mem::size_of::<u64>() => {
trace!(
@@ -118,7 +118,7 @@ where
}
Len { id } => {
let len_buf = buf.split_to(mem::size_of::<u64>());
let len = Cursor::new(len_buf).read_u64::<BigEndian>()?;
let len = BigEndian::read_u64(&*len_buf);
trace!(
"--> Parsed payload length = {}, remaining buffer length = {}",
len,
@@ -127,7 +127,7 @@ where
if len > self.max_payload_size {
return Err(too_big(len, self.max_payload_size));
}
self.state = Payload { id: id, len: len };
self.state = Payload { id, len };
}
Payload { len, .. } if buf.len() < len as usize => {
trace!(
@@ -139,7 +139,7 @@ where
}
Payload { id, len } => {
let payload = buf.split_to(len as usize);
let result = bincode::deserialize_from(&mut Cursor::new(payload));
let result = bincode::deserialize(&payload);
// Reset the state machine because, either way, we're done processing this
// message.
self.state = Id;
@@ -180,7 +180,7 @@ where
type BindTransport = Result<Self::Transport, io::Error>;
fn bind_transport(&self, io: T) -> Self::BindTransport {
Ok(io.framed(Codec::new(self.max_payload_size)))
Ok(Framed::new(io, Codec::new(self.max_payload_size)))
}
}
@@ -196,7 +196,7 @@ where
type BindTransport = Result<Self::Transport, io::Error>;
fn bind_transport(&self, io: T) -> Self::BindTransport {
Ok(io.framed(Codec::new(self.max_payload_size)))
Ok(Framed::new(io, Codec::new(self.max_payload_size)))
}
}

View File

@@ -106,7 +106,7 @@ impl Into<FutureOptions> for (reactor::Handle, Options) {
#[cfg(feature = "tls")]
fn into(self) -> FutureOptions {
let (handle, options) = self;
let mut opts = FutureOptions::default().handle(handle);
let mut opts = FutureOptions::default().max_payload_size(options.max_payload_size).handle(handle);
if let Some(tls_ctx) = options.tls_ctx {
opts = opts.tls(tls_ctx);
}
@@ -115,8 +115,8 @@ impl Into<FutureOptions> for (reactor::Handle, Options) {
#[cfg(not(feature = "tls"))]
fn into(self) -> FutureOptions {
let (handle, _) = self;
FutureOptions::default().handle(handle)
let (handle, options) = self;
FutureOptions::default().max_payload_size(options.max_payload_size).handle(handle)
}
}