Skip to content

Move trait bounds on wire::Type from use to the trait itself #1092

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

Merged

Conversation

TheBlueMatt
Copy link
Collaborator

wire::Type is only (publicly) used as the CustomMessage
associated type in CustomMessageReader, where it has additional
trait bounds on Debug and Writeable. The documentation for
Type even mentions that you need to implement Writeable because
this is the one place it is used.

To make this more clear, we move the type bounds onto the trait
itself and not on the associated type.

This is also the only practical way to build C bindings for Type
as we cannot have a concrete, single, Type struct in C which only
optionally implements various subtraits, at least not without
runtime checking of the type bounds.

Gonna need this for 0.0.101 bindings due to the above.

`wire::Type` is only (publicly) used as the `CustomMessage`
associated type in `CustomMessageReader`, where it has additional
trait bounds on `Debug` and `Writeable`. The documentation for
`Type` even mentions that you need to implement `Writeable` because
this is the one place it is used.

To make this more clear, we move the type bounds onto the trait
itself and not on the associated type.

This is also the only practical way to build C bindings for `Type`
as we cannot have a concrete, single, `Type` struct in C which only
optionally implements various subtraits, at least not without
runtime checking of the type bounds.
@TheBlueMatt TheBlueMatt added this to the 0.0.101 milestone Sep 22, 2021
Copy link
Contributor

@jkczyz jkczyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 4c81318

@codecov
Copy link

codecov bot commented Sep 22, 2021

Codecov Report

Merging #1092 (4c81318) into main (34dd7c5) will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1092   +/-   ##
=======================================
  Coverage   90.73%   90.73%           
=======================================
  Files          65       65           
  Lines       34315    34315           
=======================================
+ Hits        31134    31136    +2     
+ Misses       3181     3179    -2     
Impacted Files Coverage Δ
lightning/src/ln/wire.rs 59.68% <ø> (ø)
lightning/src/ln/functional_tests.rs 97.42% <0.00%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34dd7c5...4c81318. Read the comment docs.

@TheBlueMatt TheBlueMatt merged commit aad1803 into lightningdevkit:main Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants