feat: seq deserialization support for wildcard path#3680
Open
sirreidlos wants to merge 3 commits intotokio-rs:mainfrom
Open
feat: seq deserialization support for wildcard path#3680sirreidlos wants to merge 3 commits intotokio-rs:mainfrom
sirreidlos wants to merge 3 commits intotokio-rs:mainfrom
Conversation
`deserialize_seq` for a single param now unconditionally uses
`ValueSeqDeserializer`, altering the error kind for types like
`Vec<(u32, String)>` from `Message("Unexpected key type")` to
`UnsupportedType`. This is captured in
`test_parse_seq_tuple_unsupported_key_type`. No clean way to distinguish
wildcard-captured params from regular ones within the deserializer alone
was found without invasive changes upstream.
a645ee9 to
39a6669
Compare
This file contains hidden or 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
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.
Motivation
Closes #3621
Personally came across the need for the same feature recently, and seeing that nobody has taken it upon themselves to add the feature, I decided to do it myself.
Solution
Add
ValueSeqDeserializerfor bothPathDeserializerandValueDeserializer'sdeserialize_seq. Some code for theValueDeserializeris also duplicated to create a deserializer that can take in rawstrs, aptly namedRawStrValueDeserializer.Other solutions were explored, for example building a
PercentDecodedStrdirectly from astr, but the lifetime constraint made it impossible. Another was simply to run the decoding function again, but the (potential, unmeasured) runtime performance hit may be too off-putting.Deserialization for a single-param sequence now always goes through
ValueSeqDeserializer. This is mostly transparent, with one exception where the error type is changed fromMessage("Unexpected key type")toUnsupportedTypeas reflected in the modifiedtest_parse_seq_tuple_unsupported_key_type.