mirror of
https://github.com/OMGeeky/tarpc.git
synced 2026-01-22 11:05:22 +01:00
Remove an unused trait and a few unnecessary Send bounds (#54)
This commit is contained in:
@@ -21,7 +21,7 @@ macro_rules! future_enum {
|
||||
}
|
||||
|
||||
impl<__T, __E, $($tp),*> $crate::futures::Future for $name<$($tp),*>
|
||||
where __T: Send + 'static,
|
||||
where __T: ::std::marker::Send + 'static,
|
||||
$($inner: $crate::futures::Future<Item=__T, Error=__E>),*
|
||||
{
|
||||
type Item = __T;
|
||||
@@ -48,7 +48,7 @@ macro_rules! future_enum {
|
||||
}
|
||||
|
||||
impl<__T, __E, $($tp),*> $crate::futures::Future for $name<$($tp),*>
|
||||
where __T: Send + 'static,
|
||||
where __T: ::std::marker::Send + 'static,
|
||||
$($inner: $crate::futures::Future<Item=__T, Error=__E>),*
|
||||
{
|
||||
type Item = __T;
|
||||
@@ -370,7 +370,7 @@ macro_rules! service {
|
||||
|
||||
snake_to_camel! {
|
||||
/// The type of future returned by the fn of the same name.
|
||||
type $fn_name: $crate::futures::Future<Item=$out, Error=$error> + Send;
|
||||
type $fn_name: $crate::futures::Future<Item=$out, Error=$error>;
|
||||
}
|
||||
|
||||
$(#[$attr])*
|
||||
@@ -591,7 +591,7 @@ macro_rules! service {
|
||||
$(#[$attr])*
|
||||
#[inline]
|
||||
pub fn $fn_name(&self, $($arg: &$in_),*)
|
||||
-> impl $crate::futures::Future<Item=$out, Error=$crate::Error<$error>> + Send + 'static
|
||||
-> impl $crate::futures::Future<Item=$out, Error=$crate::Error<$error>> + 'static
|
||||
{
|
||||
$client_req
|
||||
$client_serialize_impl
|
||||
@@ -698,8 +698,7 @@ mod functional_test {
|
||||
fn other_service() {
|
||||
let _ = env_logger::init();
|
||||
let handle = Server.listen("localhost:0").unwrap();
|
||||
let client =
|
||||
super::other_service::SyncClient::connect(handle.local_addr()).unwrap();
|
||||
let client = super::other_service::SyncClient::connect(handle.local_addr()).unwrap();
|
||||
match client.foo().err().unwrap() {
|
||||
::Error::ServerDeserialize(_) => {} // good
|
||||
bad => panic!("Expected Error::ServerDeserialize but got {}", bad),
|
||||
|
||||
19
src/util.rs
19
src/util.rs
@@ -3,29 +3,10 @@
|
||||
// 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.
|
||||
|
||||
use futures;
|
||||
use std::fmt;
|
||||
use std::error::Error;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
/// A trait for easy spawning of futures.
|
||||
///
|
||||
/// `Future`s don't actually perform their computations until spawned via an `Executor`. Typically,
|
||||
/// an executor will be associated with an event loop. The `fn` provided by `Spawn` handles
|
||||
/// spawning the future on the static event loop on which tarpc clients and servers run by default.
|
||||
pub trait Spawn {
|
||||
/// Spawns a future on the default event loop.
|
||||
fn spawn(self);
|
||||
}
|
||||
|
||||
impl<F> Spawn for F
|
||||
where F: futures::Future + Send + 'static
|
||||
{
|
||||
fn spawn(self) {
|
||||
::protocol::LOOP_HANDLE.spawn(move |_| self.then(|_| Ok::<(), ()>(())))
|
||||
}
|
||||
}
|
||||
|
||||
/// A bottom type that impls `Error`, `Serialize`, and `Deserialize`. It is impossible to
|
||||
/// instantiate this type.
|
||||
#[derive(Debug)]
|
||||
|
||||
Reference in New Issue
Block a user