-
Notifications
You must be signed in to change notification settings - Fork 411
Concretize bindings templates #788
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
Concretize bindings templates #788
Conversation
Codecov Report
@@ Coverage Diff @@
## main #788 +/- ##
==========================================
+ Coverage 90.75% 90.80% +0.04%
==========================================
Files 44 44
Lines 24119 24073 -46
==========================================
- Hits 21890 21859 -31
+ Misses 2229 2214 -15
Continue to review full report at Codecov.
|
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.
Not my most meticulous review, but this LGTM 🥇
Exciting to get closer to support for wasm_bindgen
+ nice code simplifications
While the type aliasing trick works great for cbindgen, wasm_bindgen doesn't support it and requires fully-concrete types. In order to better support wasm_bindgen in the future, we do so here, adding a function which manually writes out almost the exact thing which was templated previously in concrete form. As a nice side-effect, we no longer have to allocate and free a u8 for generic parameters which were `()` (though we still do in some conversion functions, which we can get rid of when we similarly concretize all generics fully).
Previously we'd segfault trying to deref the NULL page, but there is no reason to not simply clone by creating another opaque instance with a null inner. This comes up specifically when cloning ChannelSigners as the pubkeys instance is NULL on construction before get_pubkeys is called.
26a2260
to
1d089ca
Compare
The only API change outside of additional derives is to change the inner field in `DecodeError::Io()` to an `std::io::ErrorKind` instead of an `std::io::Error`. While `std::io::Error` obviously makes more sense in context, it doesn't support Clone, and the inner error largely doesn't have a lot of value on its own.
1d089ca
to
0816cf4
Compare
0816cf4
to
c2fd683
Compare
No reason to sit on this given its Basically Just Bindings (tm). Gonna merge. Non-bindings diff is below.
|
(based on #787 because I'm too lazy to rebase).
This concertizes the templates in the bindings, making the bindings Rust code a little closer to what we end up with in C, leaning a little less on cbindgen. It also significantly reduces the template-specific type resolution logic, which is a big win.
Finally, while we're at it, we add _clone methods for template types, making downstream usage much simpler.