Parameterize CompactForm String for optional SCALE impl#35
Merged
Conversation
By default, parity-scale-codec does not provide Encode/Decode impls for an owned String. This is only provided under the "full" feature which is not used by the substrate runtime, because it should not be used for consensus critical code. So in order for the CompactForm to be integrated into the substrate runtime, or wherever the "full" feature cannot be used, then we must parameterize the `String` type so that it can be both an `&'static str` on the runtime side where it is encoded, and a `String` in client/consuming code where it is decoded.
dvdplm
approved these changes
Dec 8, 2020
Contributor
dvdplm
left a comment
There was a problem hiding this comment.
I can't say I fully understand the code surrounding your change here; the docs are a bit "academic" and I have a hard time following them at times.
The changes in this PR are straight forward and seems like a no-brainer per se.
Contributor
Author
|
I'd like @Robbepop to approve this too before merging, because he disagreed with my previous approach #19 (comment) |
Contributor
Author
Contributor
Author
|
Merged since other work already based on this |
This was referenced Jan 28, 2021
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.
By default, parity-scale-codec does not provide Encode/Decode impls for an owned String.
This is only provided under the "full" feature which is not used by the substrate runtime,
because it should not be used for consensus critical code. So in order for the CompactForm
to be integrated into the substrate runtime, or wherever the "full" feature cannot be used,
then we must parameterize the
Stringtype so that it can be both an&'static stron theruntime side where it is encoded, and a
Stringin client/consuming code where it is decoded.Note that previously I had done something similar with
OwnedFormdiscussed with @Robbepop here. But this or something similar is now required in case we want to generate the metadata directly inside the substrate runtime whereStrings are not allowed.