mirror of
https://github.com/OMGeeky/tarpc.git
synced 2026-02-23 15:49:54 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21e8883877 |
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "tarpc"
|
name = "tarpc"
|
||||||
version = "0.7.3"
|
version = "0.8.0"
|
||||||
authors = ["Adam Wright <adam.austin.wright@gmail.com>", "Tim Kuehn <timothy.j.kuehn@gmail.com>"]
|
authors = ["Adam Wright <adam.austin.wright@gmail.com>", "Tim Kuehn <timothy.j.kuehn@gmail.com>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
documentation = "https://docs.rs/tarpc"
|
documentation = "https://docs.rs/tarpc"
|
||||||
@@ -15,7 +15,7 @@ description = "An RPC framework for Rust with a focus on ease of use."
|
|||||||
travis-ci = { repository = "google/tarpc" }
|
travis-ci = { repository = "google/tarpc" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bincode = "1.0.0-alpha6"
|
bincode = "0.8"
|
||||||
byteorder = "1.0"
|
byteorder = "1.0"
|
||||||
bytes = "0.4"
|
bytes = "0.4"
|
||||||
cfg-if = "0.1.0"
|
cfg-if = "0.1.0"
|
||||||
@@ -24,8 +24,8 @@ lazy_static = "0.2"
|
|||||||
log = "0.3"
|
log = "0.3"
|
||||||
net2 = "0.2"
|
net2 = "0.2"
|
||||||
num_cpus = "1.0"
|
num_cpus = "1.0"
|
||||||
serde = "0.9"
|
serde = "1.0"
|
||||||
serde_derive = "0.9"
|
serde_derive = "1.0"
|
||||||
tarpc-plugins = { path = "src/plugins", version = "0.1.1" }
|
tarpc-plugins = { path = "src/plugins", version = "0.1.1" }
|
||||||
thread-pool = "0.1.1"
|
thread-pool = "0.1.1"
|
||||||
tokio-core = "0.1.6"
|
tokio-core = "0.1.6"
|
||||||
@@ -42,6 +42,7 @@ chrono = "0.3"
|
|||||||
env_logger = "0.3"
|
env_logger = "0.3"
|
||||||
futures-cpupool = "0.1"
|
futures-cpupool = "0.1"
|
||||||
clap = "2.0"
|
clap = "2.0"
|
||||||
|
serde_bytes = "0.10"
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dev-dependencies]
|
[target.'cfg(target_os = "macos")'.dev-dependencies]
|
||||||
security-framework = "0.1"
|
security-framework = "0.1"
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
## 0.8.0 (2017-05-05)
|
||||||
|
|
||||||
|
## Breaking Changes
|
||||||
|
This release updates tarpc to use serde 1.0.
|
||||||
|
As such, users must also update to use serde 1.0.
|
||||||
|
The serde 1.0 [release notes](https://github.com/serde-rs/serde/releases/tag/v1.0.0)
|
||||||
|
detail migration paths.
|
||||||
|
|
||||||
## 0.7.3 (2017-04-26)
|
## 0.7.3 (2017-04-26)
|
||||||
|
|
||||||
This release removes the `Sync` bound on RPC args for both sync and future
|
This release removes the `Sync` bound on RPC args for both sync and future
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ extern crate env_logger;
|
|||||||
extern crate futures;
|
extern crate futures;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
extern crate serde;
|
extern crate serde_bytes;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate tarpc;
|
extern crate tarpc;
|
||||||
extern crate tokio_core;
|
extern crate tokio_core;
|
||||||
@@ -31,7 +31,7 @@ use tarpc::util::{FirstSocketAddr, Never};
|
|||||||
use tokio_core::reactor;
|
use tokio_core::reactor;
|
||||||
|
|
||||||
service! {
|
service! {
|
||||||
rpc read(size: u32) -> serde::bytes::ByteBuf;
|
rpc read(size: u32) -> serde_bytes::ByteBuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@@ -50,7 +50,7 @@ impl Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FutureService for Server {
|
impl FutureService for Server {
|
||||||
type ReadFut = CpuFuture<serde::bytes::ByteBuf, Never>;
|
type ReadFut = CpuFuture<serde_bytes::ByteBuf, Never>;
|
||||||
|
|
||||||
fn read(&self, size: u32) -> Self::ReadFut {
|
fn read(&self, size: u32) -> Self::ReadFut {
|
||||||
let request_number = self.request_count.fetch_add(1, Ordering::SeqCst);
|
let request_number = self.request_count.fetch_add(1, Ordering::SeqCst);
|
||||||
|
|||||||
@@ -12,12 +12,11 @@ extern crate lazy_static;
|
|||||||
extern crate tarpc;
|
extern crate tarpc;
|
||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
extern crate futures;
|
extern crate futures;
|
||||||
extern crate serde;
|
extern crate serde_bytes;
|
||||||
extern crate tokio_core;
|
extern crate tokio_core;
|
||||||
|
|
||||||
use std::io::{Read, Write, stdout};
|
use std::io::{Read, Write, stdout};
|
||||||
use std::net;
|
use std::net;
|
||||||
use std::sync::Arc;
|
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time;
|
use std::time;
|
||||||
@@ -27,7 +26,7 @@ use tarpc::util::{FirstSocketAddr, Never};
|
|||||||
use tokio_core::reactor;
|
use tokio_core::reactor;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref BUF: Arc<serde::bytes::ByteBuf> = Arc::new(gen_vec(CHUNK_SIZE as usize).into());
|
static ref BUF: serde_bytes::ByteBuf = gen_vec(CHUNK_SIZE as usize).into();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_vec(size: usize) -> Vec<u8> {
|
fn gen_vec(size: usize) -> Vec<u8> {
|
||||||
@@ -39,14 +38,14 @@ fn gen_vec(size: usize) -> Vec<u8> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
service! {
|
service! {
|
||||||
rpc read() -> Arc<serde::bytes::ByteBuf>;
|
rpc read() -> serde_bytes::ByteBuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct Server;
|
struct Server;
|
||||||
|
|
||||||
impl FutureService for Server {
|
impl FutureService for Server {
|
||||||
type ReadFut = Result<Arc<serde::bytes::ByteBuf>, Never>;
|
type ReadFut = Result<serde_bytes::ByteBuf, Never>;
|
||||||
|
|
||||||
fn read(&self) -> Self::ReadFut {
|
fn read(&self) -> Self::ReadFut {
|
||||||
Ok(BUF.clone())
|
Ok(BUF.clone())
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ pub enum Error<E> {
|
|||||||
App(E),
|
App(E),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: StdError + Deserialize + Serialize + Send + 'static> fmt::Display for Error<E> {
|
impl<'a, E: StdError + Deserialize<'a> + Serialize + Send + 'static> fmt::Display for Error<E> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
Error::ResponseDeserialize(ref e) => write!(f, r#"{}: "{}""#, self.description(), e),
|
Error::ResponseDeserialize(ref e) => write!(f, r#"{}: "{}""#, self.description(), e),
|
||||||
@@ -40,7 +40,7 @@ impl<E: StdError + Deserialize + Serialize + Send + 'static> fmt::Display for Er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: StdError + Deserialize + Serialize + Send + 'static> StdError for Error<E> {
|
impl<'a, E: StdError + Deserialize<'a> + Serialize + Send + 'static> StdError for Error<E> {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
Error::ResponseDeserialize(_) => "The client failed to deserialize the response.",
|
Error::ResponseDeserialize(_) => "The client failed to deserialize the response.",
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ use {REMOTE, bincode};
|
|||||||
use future::server::Response;
|
use future::server::Response;
|
||||||
use futures::{self, Future, future};
|
use futures::{self, Future, future};
|
||||||
use protocol::Proto;
|
use protocol::Proto;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::Serialize;
|
||||||
|
use serde::de::DeserializeOwned;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
@@ -103,16 +104,16 @@ impl fmt::Debug for Reactor {
|
|||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub struct Client<Req, Resp, E>
|
pub struct Client<Req, Resp, E>
|
||||||
where Req: Serialize + 'static,
|
where Req: Serialize + 'static,
|
||||||
Resp: Deserialize + 'static,
|
Resp: DeserializeOwned + 'static,
|
||||||
E: Deserialize + 'static
|
E: DeserializeOwned + 'static
|
||||||
{
|
{
|
||||||
inner: ClientService<StreamType, Proto<Req, Response<Resp, E>>>,
|
inner: ClientService<StreamType, Proto<Req, Response<Resp, E>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Req, Resp, E> Clone for Client<Req, Resp, E>
|
impl<Req, Resp, E> Clone for Client<Req, Resp, E>
|
||||||
where Req: Serialize + 'static,
|
where Req: Serialize + 'static,
|
||||||
Resp: Deserialize + 'static,
|
Resp: DeserializeOwned + 'static,
|
||||||
E: Deserialize + 'static
|
E: DeserializeOwned + 'static
|
||||||
{
|
{
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Client { inner: self.inner.clone() }
|
Client { inner: self.inner.clone() }
|
||||||
@@ -121,8 +122,8 @@ impl<Req, Resp, E> Clone for Client<Req, Resp, E>
|
|||||||
|
|
||||||
impl<Req, Resp, E> Service for Client<Req, Resp, E>
|
impl<Req, Resp, E> Service for Client<Req, Resp, E>
|
||||||
where Req: Serialize + Send + 'static,
|
where Req: Serialize + Send + 'static,
|
||||||
Resp: Deserialize + Send + 'static,
|
Resp: DeserializeOwned + Send + 'static,
|
||||||
E: Deserialize + Send + 'static
|
E: DeserializeOwned + Send + 'static
|
||||||
{
|
{
|
||||||
type Request = Req;
|
type Request = Req;
|
||||||
type Response = Resp;
|
type Response = Resp;
|
||||||
@@ -143,13 +144,13 @@ impl<Req, Resp, E> Service for Client<Req, Resp, E>
|
|||||||
|
|
||||||
impl<Req, Resp, E> Client<Req, Resp, E>
|
impl<Req, Resp, E> Client<Req, Resp, E>
|
||||||
where Req: Serialize + 'static,
|
where Req: Serialize + 'static,
|
||||||
Resp: Deserialize + 'static,
|
Resp: DeserializeOwned + 'static,
|
||||||
E: Deserialize + 'static
|
E: DeserializeOwned + 'static
|
||||||
{
|
{
|
||||||
fn bind(handle: &reactor::Handle, tcp: StreamType, max_payload_size: u64) -> Self
|
fn bind(handle: &reactor::Handle, tcp: StreamType, max_payload_size: u64) -> Self
|
||||||
where Req: Serialize + Send + 'static,
|
where Req: Serialize + Send + 'static,
|
||||||
Resp: Deserialize + Send + 'static,
|
Resp: DeserializeOwned + Send + 'static,
|
||||||
E: Deserialize + Send + 'static
|
E: DeserializeOwned + Send + 'static
|
||||||
{
|
{
|
||||||
let inner = Proto::new(max_payload_size).bind_client(&handle, tcp);
|
let inner = Proto::new(max_payload_size).bind_client(&handle, tcp);
|
||||||
Client { inner }
|
Client { inner }
|
||||||
@@ -164,8 +165,8 @@ impl<Req, Resp, E> Client<Req, Resp, E>
|
|||||||
|
|
||||||
impl<Req, Resp, E> fmt::Debug for Client<Req, Resp, E>
|
impl<Req, Resp, E> fmt::Debug for Client<Req, Resp, E>
|
||||||
where Req: Serialize + 'static,
|
where Req: Serialize + 'static,
|
||||||
Resp: Deserialize + 'static,
|
Resp: DeserializeOwned + 'static,
|
||||||
E: Deserialize + 'static
|
E: DeserializeOwned + 'static
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||||
write!(f, "Client {{ .. }}")
|
write!(f, "Client {{ .. }}")
|
||||||
@@ -188,8 +189,8 @@ pub type ConnectFuture<Req, Resp, E> =
|
|||||||
|
|
||||||
impl<Req, Resp, E> ClientExt for Client<Req, Resp, E>
|
impl<Req, Resp, E> ClientExt for Client<Req, Resp, E>
|
||||||
where Req: Serialize + Send + 'static,
|
where Req: Serialize + Send + 'static,
|
||||||
Resp: Deserialize + Send + 'static,
|
Resp: DeserializeOwned + Send + 'static,
|
||||||
E: Deserialize + Send + 'static
|
E: DeserializeOwned + Send + 'static
|
||||||
{
|
{
|
||||||
type ConnectFut = ConnectFuture<Req, Resp, E>;
|
type ConnectFut = ConnectFuture<Req, Resp, E>;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ use {bincode, net2};
|
|||||||
use errors::WireError;
|
use errors::WireError;
|
||||||
use futures::{Async, Future, Poll, Stream, future as futures};
|
use futures::{Async, Future, Poll, Stream, future as futures};
|
||||||
use protocol::Proto;
|
use protocol::Proto;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::Serialize;
|
||||||
|
use serde::de::DeserializeOwned;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
@@ -241,7 +242,7 @@ pub fn listen<S, Req, Resp, E>(new_service: S,
|
|||||||
where S: NewService<Request = Result<Req, bincode::Error>,
|
where S: NewService<Request = Result<Req, bincode::Error>,
|
||||||
Response = Response<Resp, E>,
|
Response = Response<Resp, E>,
|
||||||
Error = io::Error> + 'static,
|
Error = io::Error> + 'static,
|
||||||
Req: Deserialize + 'static,
|
Req: DeserializeOwned + 'static,
|
||||||
Resp: Serialize + 'static,
|
Resp: Serialize + 'static,
|
||||||
E: Serialize + 'static
|
E: Serialize + 'static
|
||||||
{
|
{
|
||||||
@@ -267,7 +268,7 @@ fn listen_with<S, Req, Resp, E>(new_service: S,
|
|||||||
where S: NewService<Request = Result<Req, bincode::Error>,
|
where S: NewService<Request = Result<Req, bincode::Error>,
|
||||||
Response = Response<Resp, E>,
|
Response = Response<Resp, E>,
|
||||||
Error = io::Error> + 'static,
|
Error = io::Error> + 'static,
|
||||||
Req: Deserialize + 'static,
|
Req: DeserializeOwned + 'static,
|
||||||
Resp: Serialize + 'static,
|
Resp: Serialize + 'static,
|
||||||
E: Serialize + 'static
|
E: Serialize + 'static
|
||||||
{
|
{
|
||||||
@@ -347,7 +348,7 @@ impl<S, Req, Resp, E, I, St> BindStream<S, St>
|
|||||||
where S: NewService<Request = Result<Req, bincode::Error>,
|
where S: NewService<Request = Result<Req, bincode::Error>,
|
||||||
Response = Response<Resp, E>,
|
Response = Response<Resp, E>,
|
||||||
Error = io::Error> + 'static,
|
Error = io::Error> + 'static,
|
||||||
Req: Deserialize + 'static,
|
Req: DeserializeOwned + 'static,
|
||||||
Resp: Serialize + 'static,
|
Resp: Serialize + 'static,
|
||||||
E: Serialize + 'static,
|
E: Serialize + 'static,
|
||||||
I: AsyncRead + AsyncWrite + 'static,
|
I: AsyncRead + AsyncWrite + 'static,
|
||||||
@@ -372,7 +373,7 @@ impl<S, Req, Resp, E, I, St> Future for BindStream<S, St>
|
|||||||
where S: NewService<Request = Result<Req, bincode::Error>,
|
where S: NewService<Request = Result<Req, bincode::Error>,
|
||||||
Response = Response<Resp, E>,
|
Response = Response<Resp, E>,
|
||||||
Error = io::Error> + 'static,
|
Error = io::Error> + 'static,
|
||||||
Req: Deserialize + 'static,
|
Req: DeserializeOwned + 'static,
|
||||||
Resp: Serialize + 'static,
|
Resp: Serialize + 'static,
|
||||||
E: Serialize + 'static,
|
E: Serialize + 'static,
|
||||||
I: AsyncRead + AsyncWrite + 'static,
|
I: AsyncRead + AsyncWrite + 'static,
|
||||||
@@ -399,7 +400,7 @@ pub struct Listen<S, Req, Resp, E>
|
|||||||
where S: NewService<Request = Result<Req, bincode::Error>,
|
where S: NewService<Request = Result<Req, bincode::Error>,
|
||||||
Response = Response<Resp, E>,
|
Response = Response<Resp, E>,
|
||||||
Error = io::Error> + 'static,
|
Error = io::Error> + 'static,
|
||||||
Req: Deserialize + 'static,
|
Req: DeserializeOwned + 'static,
|
||||||
Resp: Serialize + 'static,
|
Resp: Serialize + 'static,
|
||||||
E: Serialize + 'static
|
E: Serialize + 'static
|
||||||
{
|
{
|
||||||
@@ -410,7 +411,7 @@ impl<S, Req, Resp, E> Future for Listen<S, Req, Resp, E>
|
|||||||
where S: NewService<Request = Result<Req, bincode::Error>,
|
where S: NewService<Request = Result<Req, bincode::Error>,
|
||||||
Response = Response<Resp, E>,
|
Response = Response<Resp, E>,
|
||||||
Error = io::Error> + 'static,
|
Error = io::Error> + 'static,
|
||||||
Req: Deserialize + 'static,
|
Req: DeserializeOwned + 'static,
|
||||||
Resp: Serialize + 'static,
|
Resp: Serialize + 'static,
|
||||||
E: Serialize + 'static
|
E: Serialize + 'static
|
||||||
{
|
{
|
||||||
@@ -426,7 +427,7 @@ impl<S, Req, Resp, E> fmt::Debug for Listen<S, Req, Resp, E>
|
|||||||
where S: NewService<Request = Result<Req, bincode::Error>,
|
where S: NewService<Request = Result<Req, bincode::Error>,
|
||||||
Response = Response<Resp, E>,
|
Response = Response<Resp, E>,
|
||||||
Error = io::Error> + 'static,
|
Error = io::Error> + 'static,
|
||||||
Req: Deserialize + 'static,
|
Req: DeserializeOwned + 'static,
|
||||||
Resp: Serialize + 'static,
|
Resp: Serialize + 'static,
|
||||||
E: Serialize + 'static
|
E: Serialize + 'static
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,25 +56,27 @@ macro_rules! impl_serialize {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! impl_deserialize {
|
macro_rules! impl_deserialize {
|
||||||
($impler:ident, $(@($name:ident $n:expr))* -- #($n_:expr) ) => (
|
($impler:ident, $(@($name:ident $n:expr))* -- #($n_:expr) ) => (
|
||||||
impl $crate::serde::Deserialize for $impler {
|
impl<'d> $crate::serde::Deserialize<'d> for $impler {
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
fn deserialize<impl_deserialize_D__>(
|
fn deserialize<impl_deserialize_D__>(
|
||||||
impl_deserialize_deserializer__: impl_deserialize_D__)
|
impl_deserialize_deserializer__: impl_deserialize_D__)
|
||||||
-> ::std::result::Result<$impler, impl_deserialize_D__::Error>
|
-> ::std::result::Result<$impler, impl_deserialize_D__::Error>
|
||||||
where impl_deserialize_D__: $crate::serde::Deserializer
|
where impl_deserialize_D__: $crate::serde::Deserializer<'d>
|
||||||
{
|
{
|
||||||
#[allow(non_camel_case_types, unused)]
|
#[allow(non_camel_case_types, unused)]
|
||||||
enum impl_deserialize_Field__ {
|
enum impl_deserialize_Field__ {
|
||||||
$($name),*
|
$($name),*
|
||||||
}
|
}
|
||||||
|
|
||||||
impl $crate::serde::Deserialize for impl_deserialize_Field__ {
|
impl<'d> $crate::serde::Deserialize<'d> for impl_deserialize_Field__ {
|
||||||
fn deserialize<D>(impl_deserialize_deserializer__: D)
|
fn deserialize<D>(impl_deserialize_deserializer__: D)
|
||||||
-> ::std::result::Result<impl_deserialize_Field__, D::Error>
|
-> ::std::result::Result<impl_deserialize_Field__, D::Error>
|
||||||
where D: $crate::serde::Deserializer
|
where D: $crate::serde::Deserializer<'d>
|
||||||
{
|
{
|
||||||
struct impl_deserialize_FieldVisitor__;
|
struct impl_deserialize_FieldVisitor__;
|
||||||
impl $crate::serde::de::Visitor for impl_deserialize_FieldVisitor__ {
|
impl<'d> $crate::serde::de::Visitor<'d>
|
||||||
|
for impl_deserialize_FieldVisitor__
|
||||||
|
{
|
||||||
type Value = impl_deserialize_Field__;
|
type Value = impl_deserialize_Field__;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut ::std::fmt::Formatter)
|
fn expecting(&self, formatter: &mut ::std::fmt::Formatter)
|
||||||
@@ -107,13 +109,13 @@ macro_rules! impl_deserialize {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl_deserialize_deserializer__.deserialize_struct_field(
|
impl_deserialize_deserializer__.deserialize_identifier(
|
||||||
impl_deserialize_FieldVisitor__)
|
impl_deserialize_FieldVisitor__)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Visitor;
|
struct Visitor;
|
||||||
impl $crate::serde::de::Visitor for Visitor {
|
impl<'d> $crate::serde::de::Visitor<'d> for Visitor {
|
||||||
type Value = $impler;
|
type Value = $impler;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut ::std::fmt::Formatter)
|
fn expecting(&self, formatter: &mut ::std::fmt::Formatter)
|
||||||
@@ -122,16 +124,16 @@ macro_rules! impl_deserialize {
|
|||||||
formatter.write_str("an enum variant")
|
formatter.write_str("an enum variant")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_enum<V>(self, visitor__: V)
|
fn visit_enum<V>(self, data__: V)
|
||||||
-> ::std::result::Result<Self::Value, V::Error>
|
-> ::std::result::Result<Self::Value, V::Error>
|
||||||
where V: $crate::serde::de::EnumVisitor
|
where V: $crate::serde::de::EnumAccess<'d>
|
||||||
{
|
{
|
||||||
use $crate::serde::de::VariantVisitor;
|
use $crate::serde::de::VariantAccess;
|
||||||
match visitor__.visit_variant()? {
|
match data__.variant()? {
|
||||||
$(
|
$(
|
||||||
(impl_deserialize_Field__::$name, variant) => {
|
(impl_deserialize_Field__::$name, variant) => {
|
||||||
::std::result::Result::Ok(
|
::std::result::Result::Ok(
|
||||||
$impler::$name(variant.visit_newtype()?))
|
$impler::$name(variant.newtype_variant()?))
|
||||||
}
|
}
|
||||||
),*
|
),*
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ fn too_big(payload_size: u64, max_payload_size: u64) -> io::Error {
|
|||||||
|
|
||||||
impl<Encode, Decode> Encoder for Codec<Encode, Decode>
|
impl<Encode, Decode> Encoder for Codec<Encode, Decode>
|
||||||
where Encode: serde::Serialize,
|
where Encode: serde::Serialize,
|
||||||
Decode: serde::Deserialize
|
Decode: serde::de::DeserializeOwned
|
||||||
{
|
{
|
||||||
type Item = (RequestId, Encode);
|
type Item = (RequestId, Encode);
|
||||||
type Error = io::Error;
|
type Error = io::Error;
|
||||||
@@ -76,7 +76,7 @@ impl<Encode, Decode> Encoder for Codec<Encode, Decode>
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<Encode, Decode> Decoder for Codec<Encode, Decode>
|
impl<Encode, Decode> Decoder for Codec<Encode, Decode>
|
||||||
where Decode: serde::Deserialize
|
where Decode: serde::de::DeserializeOwned
|
||||||
{
|
{
|
||||||
type Item = (RequestId, Result<Decode, bincode::Error>);
|
type Item = (RequestId, Result<Decode, bincode::Error>);
|
||||||
type Error = io::Error;
|
type Error = io::Error;
|
||||||
@@ -153,7 +153,7 @@ impl<Encode, Decode> Proto<Encode, Decode> {
|
|||||||
impl<T, Encode, Decode> ServerProto<T> for Proto<Encode, Decode>
|
impl<T, Encode, Decode> ServerProto<T> for Proto<Encode, Decode>
|
||||||
where T: AsyncRead + AsyncWrite + 'static,
|
where T: AsyncRead + AsyncWrite + 'static,
|
||||||
Encode: serde::Serialize + 'static,
|
Encode: serde::Serialize + 'static,
|
||||||
Decode: serde::Deserialize + 'static
|
Decode: serde::de::DeserializeOwned + 'static
|
||||||
{
|
{
|
||||||
type Response = Encode;
|
type Response = Encode;
|
||||||
type Request = Result<Decode, bincode::Error>;
|
type Request = Result<Decode, bincode::Error>;
|
||||||
@@ -168,7 +168,7 @@ impl<T, Encode, Decode> ServerProto<T> for Proto<Encode, Decode>
|
|||||||
impl<T, Encode, Decode> ClientProto<T> for Proto<Encode, Decode>
|
impl<T, Encode, Decode> ClientProto<T> for Proto<Encode, Decode>
|
||||||
where T: AsyncRead + AsyncWrite + 'static,
|
where T: AsyncRead + AsyncWrite + 'static,
|
||||||
Encode: serde::Serialize + 'static,
|
Encode: serde::Serialize + 'static,
|
||||||
Decode: serde::Deserialize + 'static
|
Decode: serde::de::DeserializeOwned + 'static
|
||||||
{
|
{
|
||||||
type Response = Result<Decode, bincode::Error>;
|
type Response = Result<Decode, bincode::Error>;
|
||||||
type Request = Encode;
|
type Request = Encode;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use future::client::{Client as FutureClient, ClientExt as FutureClientExt,
|
use future::client::{Client as FutureClient, ClientExt as FutureClientExt,
|
||||||
Options as FutureOptions};
|
Options as FutureOptions};
|
||||||
/// Exposes a trait for connecting synchronously to servers.
|
|
||||||
use futures::{Future, Stream};
|
use futures::{Future, Stream};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::Serialize;
|
||||||
|
use serde::de::DeserializeOwned;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::net::{SocketAddr, ToSocketAddrs};
|
use std::net::{SocketAddr, ToSocketAddrs};
|
||||||
@@ -35,8 +35,8 @@ impl<Req, Resp, E> fmt::Debug for Client<Req, Resp, E> {
|
|||||||
|
|
||||||
impl<Req, Resp, E> Client<Req, Resp, E>
|
impl<Req, Resp, E> Client<Req, Resp, E>
|
||||||
where Req: Serialize + Send + 'static,
|
where Req: Serialize + Send + 'static,
|
||||||
Resp: Deserialize + Send + 'static,
|
Resp: DeserializeOwned + Send + 'static,
|
||||||
E: Deserialize + Send + 'static
|
E: DeserializeOwned + Send + 'static
|
||||||
{
|
{
|
||||||
/// Drives an RPC call for the given request.
|
/// Drives an RPC call for the given request.
|
||||||
pub fn call(&self, request: Req) -> Result<Resp, ::Error<E>> {
|
pub fn call(&self, request: Req) -> Result<Resp, ::Error<E>> {
|
||||||
@@ -124,8 +124,8 @@ pub trait ClientExt: Sized {
|
|||||||
|
|
||||||
impl<Req, Resp, E> ClientExt for Client<Req, Resp, E>
|
impl<Req, Resp, E> ClientExt for Client<Req, Resp, E>
|
||||||
where Req: Serialize + Send + 'static,
|
where Req: Serialize + Send + 'static,
|
||||||
Resp: Deserialize + Send + 'static,
|
Resp: DeserializeOwned + Send + 'static,
|
||||||
E: Deserialize + Send + 'static
|
E: DeserializeOwned + Send + 'static
|
||||||
{
|
{
|
||||||
fn connect<A>(addr: A, options: Options) -> io::Result<Self>
|
fn connect<A>(addr: A, options: Options) -> io::Result<Self>
|
||||||
where A: ToSocketAddrs
|
where A: ToSocketAddrs
|
||||||
@@ -154,8 +154,8 @@ struct RequestHandler<Req, Resp, E, S> {
|
|||||||
|
|
||||||
impl<Req, Resp, E> RequestHandler<Req, Resp, E, FutureClient<Req, Resp, E>>
|
impl<Req, Resp, E> RequestHandler<Req, Resp, E, FutureClient<Req, Resp, E>>
|
||||||
where Req: Serialize + Send + 'static,
|
where Req: Serialize + Send + 'static,
|
||||||
Resp: Deserialize + Send + 'static,
|
Resp: DeserializeOwned + Send + 'static,
|
||||||
E: Deserialize + Send + 'static
|
E: DeserializeOwned + Send + 'static
|
||||||
{
|
{
|
||||||
/// Creates a new `RequestHandler` by connecting a `FutureClient` to the given address
|
/// Creates a new `RequestHandler` by connecting a `FutureClient` to the given address
|
||||||
/// using the given options.
|
/// using the given options.
|
||||||
@@ -175,8 +175,8 @@ impl<Req, Resp, E> RequestHandler<Req, Resp, E, FutureClient<Req, Resp, E>>
|
|||||||
|
|
||||||
impl<Req, Resp, E, S> RequestHandler<Req, Resp, E, S>
|
impl<Req, Resp, E, S> RequestHandler<Req, Resp, E, S>
|
||||||
where Req: Serialize + 'static,
|
where Req: Serialize + 'static,
|
||||||
Resp: Deserialize + 'static,
|
Resp: DeserializeOwned + 'static,
|
||||||
E: Deserialize + 'static,
|
E: DeserializeOwned + 'static,
|
||||||
S: Service<Request = Req, Response = Resp, Error = ::Error<E>>,
|
S: Service<Request = Req, Response = Resp, Error = ::Error<E>>,
|
||||||
S::Future: 'static
|
S::Future: 'static
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ use futures::{Future, future as futures};
|
|||||||
use futures::sync::oneshot;
|
use futures::sync::oneshot;
|
||||||
#[cfg(feature = "tls")]
|
#[cfg(feature = "tls")]
|
||||||
use native_tls_inner::TlsAcceptor;
|
use native_tls_inner::TlsAcceptor;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::Serialize;
|
||||||
|
use serde::de::DeserializeOwned;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
@@ -110,7 +111,7 @@ pub fn listen<S, Req, Resp, E>(new_service: S,
|
|||||||
<S::Instance as Service>::Future: Send + 'static,
|
<S::Instance as Service>::Future: Send + 'static,
|
||||||
S::Response: Send,
|
S::Response: Send,
|
||||||
S::Error: Send,
|
S::Error: Send,
|
||||||
Req: Deserialize + 'static,
|
Req: DeserializeOwned + 'static,
|
||||||
Resp: Serialize + 'static,
|
Resp: Serialize + 'static,
|
||||||
E: Serialize + 'static
|
E: Serialize + 'static
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,9 +60,9 @@ impl Serialize for Never {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Please don't try to deserialize this. :(
|
// Please don't try to deserialize this. :(
|
||||||
impl Deserialize for Never {
|
impl<'a> Deserialize<'a> for Never {
|
||||||
fn deserialize<D>(_: D) -> Result<Self, D::Error>
|
fn deserialize<D>(_: D) -> Result<Self, D::Error>
|
||||||
where D: Deserializer
|
where D: Deserializer<'a>
|
||||||
{
|
{
|
||||||
panic!("Never cannot be instantiated!");
|
panic!("Never cannot be instantiated!");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user