Skip to content
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

feature: Derive Display for all aries messages #1069

Merged
merged 3 commits into from
Nov 30, 2023

Conversation

Patrik-Stas
Copy link
Contributor

@Patrik-Stas Patrik-Stas commented Nov 25, 2023

  • Derives Display trait for all aries messages
  • Removed default Decorators type parameter D = NoDecorators - turned out somewhat problematic in conjunction with the custom Display proc macro. Not a big price to pay though, only slightly inconveniences developer working in messages crate, but not messages consumers.

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (6e718c2) 0.05% compared to head (a861b63) 0.05%.

Files Patch % Lines
aries/messages/src/msg_parts.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1069   +/-   ##
=====================================
  Coverage   0.05%   0.05%           
=====================================
  Files        471     471           
  Lines      24009   24009           
  Branches    4306    4294   -12     
=====================================
  Hits          13      13           
  Misses     23995   23995           
  Partials       1       1           
Flag Coverage Δ
unittests-aries-vcx 0.05% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Patrik-Stas Patrik-Stas force-pushed the feature/messages-display branch from 8b2bf0f to 0565c52 Compare November 25, 2023 23:27
@nain-F49FF806 nain-F49FF806 requested review from nain-F49FF806 and removed request for nain-F49FF806 November 27, 2023 09:06
@nain-F49FF806 nain-F49FF806 added the review:level-2 At least 2 approvals required for merge label Nov 27, 2023
nain-F49FF806
nain-F49FF806 previously approved these changes Nov 27, 2023
Copy link
Member

@nain-F49FF806 nain-F49FF806 left a comment

Choose a reason for hiding this comment

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

I can't comment on display_as_json code, as that's beyond my understanding, but other than that, LGTM!

#[builder(build_method(vis = "", name = __build))]
pub struct MsgParts<C, D = NoDecorators> {
pub struct MsgParts<C, D> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please specify the problem that the default type was causing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prompted me to dig into this more - the issue was the proc macro was too simplistic, it was generating stuff like

impl<C, D = NoDecorators> std::fmt::Display for MsgParts<C, D>
    where
        C: serde::Serialize,
        D: serde::Serialize,

while is should had been

impl<C, D> std::fmt::Display for MsgParts<C, D>
    where
        C: serde::Serialize,
        D: serde::Serialize,

This is addressed now, syn crate has useful function split_for_impl available for Generics type, which allows to work with the generics related statements in more granular fashion.

So I am re-introducing the default NoDecorators type, reverting some of the changes done here

Copy link
Contributor

Choose a reason for hiding this comment

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

I hope that the fact that the decision to rather modify the sites of usage instead of fixing the macro seemed as a better approach is more about due to skill issue rather than the fact that procedural macros are on harder to maintain :) Probably both, though...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mirgee I think you misunderstood me, I fixed the macro. No change to callsites anymore

Copy link
Contributor

@mirgee mirgee Nov 29, 2023

Choose a reason for hiding this comment

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

@Patrik-Stas No, I am talking about the initial decision (hence the past tense there).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah. In fact I misread. Indeed exactly as you said, it's definitely objectively better to make the macro more robust.

@Patrik-Stas Patrik-Stas requested a review from mirgee November 29, 2023 00:07
@Patrik-Stas Patrik-Stas force-pushed the feature/messages-display branch 3 times, most recently from 8c4bea2 to 68f2df7 Compare November 29, 2023 19:17
Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
@Patrik-Stas Patrik-Stas force-pushed the feature/messages-display branch from 68f2df7 to a861b63 Compare November 29, 2023 19:47
@Patrik-Stas Patrik-Stas merged commit 056b45e into main Nov 30, 2023
27 checks passed
@Patrik-Stas Patrik-Stas deleted the feature/messages-display branch November 30, 2023 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review:level-2 At least 2 approvals required for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants