Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove Unpin requirement from Transport #399

Merged
merged 3 commits into from
Nov 2, 2020
Merged

Conversation

e00E
Copy link
Contributor

@e00E e00E commented Oct 30, 2020

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.

e00E added 2 commits October 30, 2020 09:34
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,
Copy link
Contributor Author

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.

Copy link
Owner

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,
Copy link
Owner

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.

@tomusdrw tomusdrw merged commit c8a1aad into tomusdrw:master Nov 2, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants