-
Notifications
You must be signed in to change notification settings - Fork 12
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 BoxFuture from core and replace with manual future impl #30
Conversation
I agree with the decision to not require I never know if polling twice is considered "undefined behavior" by default, but perhaps it's a good idea to document the panic possibility somewhere. Reviewed 4 of 4 files at r1. core/src/lib.rs, line 172 at r1 (raw file):
This is mostly a style preference, but I usually do:
core/src/lib.rs, line 181 at r1 (raw file):
This turbo-fish appears to be unnecessary. Or is this intentional for additional clarity? core/src/macros.rs, line 33 at r1 (raw file):
I suggest calling this core/src/response.rs, line 33 at r1 (raw file):
This turbo-fish is also unnecessary, like above. core/src/response.rs, line 36 at r1 (raw file):
Another small nitpick, Nothing serious, just a suggestion. http/src/lib.rs, line 123 at r1 (raw file):
Can the fact that I would suggest just calling it Comments from Reviewable |
I have seen standard futures with this behavior, without even documenting it: mullvad/system-configuration-rs#8 (comment) And the docs for the Review status: 2 of 4 files reviewed at latest revision, 7 unresolved discussions. core/src/lib.rs, line 172 at r1 (raw file): Previously, jvff (Janito Vaqueiro Ferreira Filho) wrote…
Interesting. I had completely missed the existence of core/src/lib.rs, line 181 at r1 (raw file): Previously, jvff (Janito Vaqueiro Ferreira Filho) wrote…
It indeed works without it. Either it was required in some previous iteration of the code or I just thought it was and added it. No, not added for clarity on purpose. I removed it. core/src/response.rs, line 33 at r1 (raw file): Previously, jvff (Janito Vaqueiro Ferreira Filho) wrote…
Removed. core/src/response.rs, line 36 at r1 (raw file): Previously, jvff (Janito Vaqueiro Ferreira Filho) wrote…
True. I have mixed feelings about What I think I'm against is when a ...
if check_something {
bail!(ErrorKind::SomethingWrong);
}
... Because then it's used in the same way as http/src/lib.rs, line 123 at r1 (raw file): Previously, jvff (Janito Vaqueiro Ferreira Filho) wrote…
It is defined in the But I don't have an extremely strong opinion. I like to express that it's a Comments from Reviewable |
Review status: 2 of 4 files reviewed at latest revision, 6 unresolved discussions. core/src/macros.rs, line 33 at r1 (raw file): Previously, jvff (Janito Vaqueiro Ferreira Filho) wrote…
You mean because it could also represent some other attribute, such as Comments from Reviewable |
Btw. Panicing is not undefined behavior. What a panic is and how it's handled is fully defined and known. Undefined behavior is Review status: 1 of 4 files reviewed at latest revision, 6 unresolved discussions. Comments from Reviewable |
Review status: 1 of 4 files reviewed at latest revision, 7 unresolved discussions. core/src/lib.rs, line 181 at r2 (raw file):
What do you think about storing the The trace logging will still print the expected ID of the response, and since we trace log when sending the request it's still possible to correlate responses with requests if one read the logs. So it did not remove something crucial for debugging, only made it a bit less convenient to follow the flow. Comments from Reviewable |
Reviewed 1 of 4 files at r1, 2 of 3 files at r2, 1 of 1 files at r3. Comments from Reviewable |
"Undefined behavior" might have been a poor choice of words, but it was the closest I got to what I meant. The contract doesn't specify what happens if a I think not documenting the panic is okay though, if the user breaks the contract, it's better if he finds out ASAP. Reviewed 2 of 3 files at r2, 1 of 1 files at r3. core/src/lib.rs, line 181 at r2 (raw file): Previously, faern (Linus Färnstrand) wrote…
If it's only used for logging and avoids a clone, I think it's a good change. If we need to pass it into core/src/response.rs, line 36 at r1 (raw file): Previously, faern (Linus Färnstrand) wrote…
I see your point. I usually avoid the extra key presses, but I don't mind it being different and I believe consistency is more important. If you prefer to prioritize expression-returns instead of http/src/lib.rs, line 123 at r1 (raw file): Previously, faern (Linus Färnstrand) wrote…
Now I understand why. I think it's a good stepping stone for a proper type in the future. Perhaps adding a Comments from Reviewable |
Review status: 3 of 4 files reviewed at latest revision, 3 unresolved discussions. http/src/lib.rs, line 123 at r1 (raw file): Previously, jvff (Janito Vaqueiro Ferreira Filho) wrote…
I ended up removing the Comments from Reviewable |
Reviewed 1 of 1 files at r4. Comments from Reviewable |
So here is an initial step in reducing boxed futures. Instead of saying that the
Transport
trait should always returnBoxFuture<Vec<u8>, E>
we can be more general and say that it must specify atype Future: Future<Item = Vec<u8>>
more or less. Now I just moved theBoxFuture
into the http crate and named itHttpFuture
. So in practice this becomes the exact same thing. But no longer enforced incore
, which makes it possible to now write transport implementations that return non-boxed futures.I don't want to put a
Clone
bound on the error type, so that forces me to only allow callingpoll
once on anRpcRequest
that is in the error state (can only happen if the serialization of the method call failed).This change is