-
Notifications
You must be signed in to change notification settings - Fork 339
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
Expose impl_writeable_msg
#1976
Expose impl_writeable_msg
#1976
Conversation
6a338ac
to
8e41db0
Compare
8e41db0
to
99fe52e
Compare
Codecov ReportBase: 90.71% // Head: 90.71% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1976 +/- ##
=======================================
Coverage 90.71% 90.71%
=======================================
Files 97 97
Lines 50677 50676 -1
Branches 50677 50676 -1
=======================================
+ Hits 45971 45972 +1
+ Misses 4706 4704 -2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
It seems like it would be an improvement to support serializing TLV fields as other than just |
/// [`Readable`]: crate::util::ser::Readable | ||
/// [`Writeable`]: crate::util::ser::Writeable | ||
/// [`CustomMessageReader`]: crate::ln::wire::CustomMessageReader | ||
#[macro_export] | ||
macro_rules! impl_writeable_msg { | ||
($st:ident, {$($field:ident),* $(,)*}, {$(($type: expr, $tlvfield: ident, $fieldty: tt)),* $(,)*}) => { | ||
impl $crate::util::ser::Writeable for $st { | ||
fn write<W: $crate::util::ser::Writer>(&self, w: &mut W) -> Result<(), $crate::io::Error> { | ||
$( self.$field.write(w)?; )* |
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.
This requires a use $crate::util::ser::Writeable
, no?
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.
Hm, doesn't seem so for the doctest, and also seems to work in a trivial freestanding example?
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.
Right, in your example you have an explicit use lightning::util::ser::Writeable;
, my point was that if there isn't one in the file in question it needs to be in the macro.
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 sure. a) the example builds fine without the import, it is only needed for the my_custom_msg.write
call. Initial version with just the impl works just fine b) If I add the use
statement to the macro it's immediately marked as unused. 🤷♂️
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.
Huh, that's...very surprising to me. Whatever, then.
I agree we should make it support non- |
By user request, we expose the
impl_writeable_msg
macro which can be useful for implementing custom message types.