-
Notifications
You must be signed in to change notification settings - Fork 17
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
implement optional async support and remove nested result type in response #150
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This creates async HTTP client traits which mirror the existing sync ones. It also reimplements sync in terms of async, since we can use now_or_never as an escape hatch to get back to sync land, but the reverse is not possible. One ugly wart is that there's no good escape hatch to convert the sync-reader-in-async-wrapper response body back to a sync reader other than an unsafe pointer cast. No async routes generated yet; that's coming next.
…use the async ones instead
… on, for compatibility
this helps users who have no-default-features but also default_client; they want all the routes in the old places
…penssl and native-tls which we don't use
Then this can be used by the oauth2 code to provide better responses when tokens are bogus
…auth access tokens
We're using HTTP2 where it's just a repeat of the code number anyway, so it adds no value.
not just 2.0.0; the signature of ureq::Response::into_reader() was changed in 2.5.0
As long as we're doing this big of a change, might as well do the error-flattening change too. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The new features controlling this are
async_routes
which enables compiling the async functions, and anddefault_async_client
which enables a default HTTP client based on reqwest.For most current use cases this should be a fairly seamless transition, as I've made great pains to ensure that types are in the same locations unless you use the new features.
The one thing which will require manual updates is the return value from most functions has changed from
Result<Result<T, E, dropbox_sdk::Error>
toResult<T, dropbox_sdk::Error<E>>
. That is, code which previously did:should now look like:
The thing is, most code doesn't look like this and just wants to use the
?
operator to pass errors up, so that's now easier to do.If users have implemented a custom HTTP client, they will need to rework it a lot, as the HTTP client traits have been completely rewritten and are very different. That said, the new trait moves more things to the helper code, so implementing a custom client should be simpler now.
This change violates our MSRV policy a bit (requiring rust 1.75.0 which is only 10 months old instead of the desired 12) so I'm proposing to land this as a beta release for now.
Checklist
General Contributing
RELEASE_NOTES.md
file, or believe it's not necessary for this change.Validation
A copy of the
demo
example has been made (calleddemo-async
) which uses the default async client, which acts as a decent integration test.The CI scripts have been updated to check things under both sync and async modes.