Merged
Conversation
parity-scale-codec::{Encode|Decode}
335a488 to
a7bffa0
Compare
a7bffa0 to
1199edf
Compare
parity-scale-codec::{Encode|Decode}parity-scale-codec
parity-scale-codec
Collaborator
Author
|
@recmo fyi it's ready for review |
recmo
approved these changes
Oct 24, 2022
Owner
recmo
left a comment
There was a problem hiding this comment.
Looks great! Thanks for the contribution!
src/support/scale.rs
Outdated
| } | ||
| } | ||
|
|
||
| // TODO: Use nightly generic const expressions to validate that BITS parameter is less than 536 |
Owner
There was a problem hiding this comment.
A workaround is to add assert!(BITS < 536)s in the constructs. Since this is const it will optimize away if everything is good. If the users makes a mistake, it will panic the moment a type is constructed. Presumably the users will at least construct the type during testing.
Owner
There was a problem hiding this comment.
Ah, you have this with assert_compact_supported, I would add it to the From construtors too.
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
Implement SCALE codec for
Uintalong with the compact types.Solution
Most of the compact encoding implementation is from https://github.com/paritytech/parity-scale-codec/blob/ca03f7fd981855b7cd6348fe32a9831e8e142813/src/compact.rs, but adapted to work with bits number other than power of 2 and up to 536 (according to the spec) instead of 128.
PR Checklist