-
Notifications
You must be signed in to change notification settings - Fork 470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Unpin requirement from Transport #399
Conversation
Here I was unable to convert SubscriptionStream to `impl Stream` because it has additional methods and runs code on drop. To get rid of the Unpin requirement anyway we use pin_project (https://docs.rs/pin-project/1.0.1/pin_project/).
@@ -20,10 +24,10 @@ impl<A, B, AOut, BOut> Transport for Either<A, B> | |||
where | |||
A: Transport<Out = AOut>, | |||
B: Transport<Out = BOut>, | |||
AOut: futures::Future<Output = error::Result<rpc::Value>> + Unpin + 'static, | |||
BOut: futures::Future<Output = error::Result<rpc::Value>> + Unpin + 'static, | |||
AOut: futures::Future<Output = error::Result<rpc::Value>> + 'static + Send, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think previously EitherTransport did not require Send but now it does because of BoxFuture. I wasn't able to get the types to work out otherwise. Technically one could duplicate this code and use LocalBoxFuture to get rid of the Send requirement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO acceptable trade-off for async code for now.
@@ -20,10 +24,10 @@ impl<A, B, AOut, BOut> Transport for Either<A, B> | |||
where | |||
A: Transport<Out = AOut>, | |||
B: Transport<Out = BOut>, | |||
AOut: futures::Future<Output = error::Result<rpc::Value>> + Unpin + 'static, | |||
BOut: futures::Future<Output = error::Result<rpc::Value>> + Unpin + 'static, | |||
AOut: futures::Future<Output = error::Result<rpc::Value>> + 'static + Send, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO acceptable trade-off for async code for now.
This is based on the other PR for eth_subscribe so it includes that commit too. After making use of pin-project there I realized I could do this directly for CallFuture and thus make Transport no longer require Unpin even without removing all of the uses of CallFuture. There are still uses of Unpin in a couple of tests, http.rs and ws.rs . It looks like those are benign because everything still compiles but I am a little bit wary that this might have some unexpected consequence.