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

zv,zn: manually implement Debug for Str, *Name and ObjectPath #394

Closed
wants to merge 4 commits into from

Conversation

MaxVerevkin
Copy link
Contributor

@MaxVerevkin MaxVerevkin commented Jun 27, 2023

Before:

[src/main.rs:24] event = Msg {
    type: Signal,
    sender: UniqueName(
        Str(
            Borrowed(
                "org.freedesktop.DBus",
            ),
        ),
    ),
    path: ObjectPath(
        "/org/freedesktop/DBus",
    ),
    iface: InterfaceName(
        Str(
            Borrowed(
                "org.freedesktop.DBus",
            ),
        ),
    ),
    member: MemberName(
        Str(
            Borrowed(
                "NameOwnerChanged",
            ),
        ),
    ),
    body: Signature(
        "sss",
    ),
}

After:

[src/main.rs:24] event = Msg {
    type: Signal,
    sender: "org.freedesktop.DBus",
    path: "/org/freedesktop/DBus",
    iface: "org.freedesktop.DBus",
    member: "NameOwnerChanged",
    body: Signature(
        "sss",
    ),
}

Fixes #431.

@MaxVerevkin
Copy link
Contributor Author

As a follow-up PR, I think Message's Debug impl can be further improved to be

[src/main.rs:24] event = Msg {
    type: Signal,
    sender: "org.freedesktop.DBus",
    path: "/org/freedesktop/DBus",
    iface: "org.freedesktop.DBus",
    member: "NameOwnerChanged",
    body_signature: "sss",
}

@zeenix
Copy link
Contributor

zeenix commented Jun 28, 2023

As a follow-up PR, I think Message's Debug impl can be further improved to be

Nice but:

  1. these are related so should ideally get it all done in the same PR.
  2. Message's impl seems a lot more condensed. We should keep it consistent.

@MaxVerevkin
Copy link
Contributor Author

Message's impl seems a lot more condensed. We should keep it consistent.

Could you explain what you mean?

@zeenix
Copy link
Contributor

zeenix commented Jun 28, 2023

Message's impl seems a lot more condensed. We should keep it consistent.

Could you explain what you mean?

Good that you asked. I totally missed how that both outputs are of Message, and that the second one will be an improvement on the first. :) So nm that point.

@MaxVerevkin
Copy link
Contributor Author

As a follow-up PR, I think Message's Debug impl can be further improved to be

[src/main.rs:24] event = Msg {
    type: Signal,
    sender: "org.freedesktop.DBus",
    path: "/org/freedesktop/DBus",
    iface: "org.freedesktop.DBus",
    member: "NameOwnerChanged",
    body_signature: "sss",
}

Actually I think it's better to achieve this by manually implementing Debug for *Name, ObjectPath and Signature. Note that it does not interfere with #379.

@zeenix
Copy link
Contributor

zeenix commented Jun 28, 2023

Actually I think it's better to achieve this by manually implementing Debug for *Name, ObjectPath and Signature.

Sure.

Note that it does not interfere with #379.

I thought so. Was just linking the PRs for their close similarity.

@MaxVerevkin MaxVerevkin changed the title zv: manually implement Debug for Str zv: manually implement Debug for Str, *Name and ObjectPath Jun 28, 2023
@MaxVerevkin MaxVerevkin changed the title zv: manually implement Debug for Str, *Name and ObjectPath zv,zn: manually implement Debug for Str, *Name and ObjectPath Jun 28, 2023
@zeenix
Copy link
Contributor

zeenix commented Jun 28, 2023

@MaxVerevkin btw, did I mention our newest strong recommendation to have emoji prefixes on git commits? They also make for good release notes: https://github.com/dbus2/zbus/releases/tag/zvariant-3.15.0 (I also rollod out zbus_names release but most commits there were lacking the emojis so the release notes don't look at good).

I added recently to our contributions guide, with recommendations for tools to use for doing it easily.

@MaxVerevkin
Copy link
Contributor Author

btw, did I mention our newest strong recommendation to have emoji prefixes on git commits?

No, I noticed the use of emojis in the git log, but I wasn't aware it is a strong recommendation to use them. Personally not a fan, but I'll add them to my commit messages.

@zeenix
Copy link
Contributor

zeenix commented Jun 28, 2023

No, I noticed the use of emojis in the git log, but I wasn't aware it is a strong recommendation to use them.

I think it adds more than just aesthetics. It's easier to browse through the history with them. A picture is worth a thousand words they say. :)

Personally not a fan, but I'll add them to my commit messages.

Thank you! 🙏 If nothing else than you'll be doing it for consistency. Maybe you'll learn to like them, who knows. :)

@MaxVerevkin MaxVerevkin force-pushed the str-debug branch 2 times, most recently from 38a30e7 to a3889ee Compare July 1, 2023 08:17
@MaxVerevkin
Copy link
Contributor Author

MaxVerevkin commented Jul 1, 2023

Also some emojis don't work with some editors vim that well:
image

@zeenix
Copy link
Contributor

zeenix commented Jul 1, 2023

Also some emojis don't work with some editors vim that well:

I also use vim so this affects me too, just that I never used that emoji. :) A couple of things:

  1. This is a gimoji issue and since the it has its own emoji db (copied over from gitmoji project but now separate), we can replace it with one that works.
  2. There are other emojis that will fit the purpose here:
🚸 :children_crossing: Improve user experience / usability. 
🏷️ :label:                        Add or update types.

Copy link
Contributor

@zeenix zeenix left a comment

Choose a reason for hiding this comment

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

Mostly just commit message improvements left. LGTM otherwise.

@@ -120,6 +120,12 @@ impl Display for BusName<'_> {
}
}

impl Debug for BusName<'_> {
Copy link
Contributor

Choose a reason for hiding this comment

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

The commit log (manually implement Debug for *Name) doesn't mention the rationale. Manual impl is an (no pun intended) implementation detail, not the summary of the change. How about:

zn: Improved debug repr for *Name

Improve debug representation of *Name through a manual impl of `Debug`.

Before:

<output>

After:

<output>

Copy link
Contributor

Choose a reason for hiding this comment

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

similar for the other Debug impl commits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think "transparent impl" is a good term to explain this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps? or go with my suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I repeat it in each commit msg?

Copy link
Contributor

@zeenix zeenix Jul 30, 2023

Choose a reason for hiding this comment

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

Should I repeat it in each commit msg?

repeating is fine (atomic commits).

zvariant/src/object_path.rs Outdated Show resolved Hide resolved
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple("ObjectPath").field(&self.as_str()).finish()
Debug::fmt(self.as_str(), f)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to document briefly in the commit description, what was removed.

@MaxVerevkin MaxVerevkin marked this pull request as draft July 4, 2023 21:15
@zeenix
Copy link
Contributor

zeenix commented Jul 26, 2023

@MaxVerevkin is this still Draft?

@MaxVerevkin
Copy link
Contributor Author

It is draft is a sense that I haven't addressed review feedback. I'll try to do it soon.

@MaxVerevkin MaxVerevkin marked this pull request as ready for review July 30, 2023 13:38
@zeenix
Copy link
Contributor

zeenix commented Aug 6, 2023

@SeaDve seems @MaxVerevkin doesn't have time to finish this. Feel free to do that in a separate PR if you want to work on this.

Since git doesn't allow multiple authors, when you modify a commit you can either:

  • override the author of the commit with your name and put Based on a patch from NAME <EMAIL>. Or
  • Put Co-authored by: YOUR_NAME <YOUR_EMAIL> at the bottom of the commit.

Based on how much you had to modify the commit.

@zeenix
Copy link
Contributor

zeenix commented Aug 17, 2023

@SeaDve do you think you'll have time to do this soon?

@SeaDve
Copy link
Contributor

SeaDve commented Aug 17, 2023

@SeaDve do you think you'll have time to do this soon?

Possibly on friday or saturday this week

@SeaDve
Copy link
Contributor

SeaDve commented Aug 19, 2023

I opened a separate PR with different implementation

@zeenix
Copy link
Contributor

zeenix commented Aug 19, 2023

closing in favour of #450

@zeenix zeenix closed this Aug 19, 2023
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.

Simplify/Improve Debug implementations
3 participants