Export parse_as_response_type
functions
#395
Merged
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.
We allow two different ways to work with this library.
The main way is to use the
WpApiClient
type which exposes endpoint specific request executors which executes the request and parses the response as such:We also provide an alternative way where building & executing the request as well as parsing it has to be done in individual steps. We always allowed building the request with the
WpApiRequestBuilder
, however one had to manually parse it. This is relatively easy to do in Rust by using theWpNetworkResponse::parse
function, but native wrappers had to implement a parser of their own.This PR generates these individual parsers, so native wrappers can use the Rust response parser. Here is how that looks in
Kotlin
:This looks very similar to the
WpApiClient
approach, but here we execute the given request ourselves and then pick the correct parser. Note that this approach isn't recommended unless you need the extra flexibility because it's both easier and safer to use theWpApiClient
since it'll choose the correct parser for you.