Remove use of ExtractType in deserialize_any#569
Merged
wycats merged 6 commits intonushell:masterfrom Sep 2, 2019
Merged
Conversation
The main point of this struct seems to be debugging, as key_struct_field is unused except for debugging.
There are still tagged bools in use so we can't remove the ExtractType implementation.
Contributor
|
@est31 Honestly, you know serde better than I do. Thanks for this work and all of your work getting us on stable! |
Member
Contributor
Author
|
@androbtech yeah this is likely a regression caused by this PR. Sorry for the inconvenience! Will try to get a fix done by tomorrow. |
Contributor
Author
|
Hmmm nevermind, it wasn't this PR but #579. |
elferherrera
pushed a commit
to elferherrera/nushell
that referenced
this pull request
Feb 7, 2022
* Add metadata command * Add string interpolation to testing
kubouch
pushed a commit
that referenced
this pull request
Feb 7, 2022
* Add metadata command * Add string interpolation to testing
Hofer-Julian
pushed a commit
to Hofer-Julian/nushell
that referenced
this pull request
Jan 27, 2023
Stars were incorrectly escaped
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.
This removes use of the ExtractType trait from the deserialize_any function by changing the code to never call it. The ultimate goal is to remove use of specialization.
ExtractType and its use of specialization exists to allow deserialization of cli arguments. For each command, there is a struct with some members and serde's Deserialize trait is being derived. This is the argument struct for the mv command:
The cli arguments input by an user are being converted from a
CallInfostruct to that command-specific struct usingConfigDeserializer. The only uses of theExtractTypetrait in the codebase are in itsDeserializerimplementation where they help avoiding having to use serde beyond iterating over the fields of the command-specific structs: any field of a cli param is expected to be readable from aTagged<Value>.In order to reduce usage of
ExtractType, this PR brings more data into format understandable by serde.The command
rg "\(Deserialize\)][^}]*\}" -U src/commands/*provides a list of command-param-structs that we have to handle. The field types can be extracted usingrg "\(Deserialize\)][^}]*\}" -U src/commands/* | rg ": .*: " | sed 's/^.*: //' | sort | uniq:Previously, all these types were parsed from
Tagged<Value>instances using theExtractTypetrait. Now, serde with its outside-to-inside model is being used to handle the logic to deserialize Vec<>, bool, Option<>, tuples, but we still defer toExtractTypewhen something is encountered that doesn't fit into the serde data model like Tagged or Block. Handling these via serde as well is still possible and subject of future PRs.Useful commands for testing:
cc #362