-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use scale-encode and scale-decode, and enable zero-copy decoding via Visitor trait #25
Conversation
encode_decode_check(123u32, Value::u128(123)); | ||
encode_decode_check(123u64, Value::u128(123)); | ||
encode_decode_check(123u128, Value::u128(123)); | ||
//// Todo [jsdw]: Can we test this if we need a TypeInfo param?: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anything you want fix in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this has been around a while, so I think it's fine; these u256/i256 types are a pain in general to work with!
(hiding whitespace in the github UI def helps given the space to tab change, sorry about that!)
src/scale_impls/encode.rs
Outdated
} | ||
// For other types, skip our value past a 1-value composite and try again, else error. | ||
_ => { | ||
if value.len() == 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you do something like to fix the unwrap:
let mut it = values.values();
if let Some(v) = it.next() {
if it.peek().is_none() {
return inner_val.encode_as_type_to(type_id, types, out);
}
}
Err(Error::new(ErrorKind::WrongShape { actual: Kind::Tuple, expected: type_id }))
otherwise, just change it to an expect it easier to follow
@@ -1,4 +1,5 @@ | |||
hard_tabs = true | |||
hard_tabs = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
are you tired of tabs? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's mainly just that subxt, scale-decode and scale-encode all use spaces :)
But also, a really annoying thing I run into with tabs is making doc examples; I can't remember the exact issue but something like the IDE tries to make things tabs but cargo complains about tabs in doc comments; either way it all "just works" with spaces I guess (and spaces also seem to be the default anyway)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks clean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice work! 👍
Part of a series:
This PR:
scale-encode
to encodeValues
.scale-decode
and ensureValue
also implsDecodeAsType
andDecodeAsFields
/EncodeAsFields
where appropriate.The net effect of this is that
Values
share much of their encode and decode logic with every other static type now.