Skip to content

Conversation

@Frando
Copy link
Member

@Frando Frando commented Jul 29, 2025

This has a couple of refactorings on top of #51:

  • Move the wrap functionality into a wrap attribute on variants, and adjust docs accordingly. I think this is better, it is a separate feature from the rpc types, and the rpc attr easily gets too long for a single line otherwise.
  • Add support to set visibility and additional derives for wrap types. This makes this far more useful, otherwise you can't use the wrap argument as soon as you need a derive (e.g. Clone) on the generated type. By refactoring the code a bit, this barely adds more code to the macro.
  • Make tx argument in rpc attribute optional, and change parsing to not use a map but just look for the only two arguments (rx and tx)
  • Refactor the derive crate to be a bit simpler, and easier to follow by putting the main macro up to the top of the file
  • Adds a full example to crate docs

The refactor of the derive crate has no changes apart from the wrap changes outlined above.

@Frando Frando force-pushed the Frando/wrap-cleanup branch 3 times, most recently from cf0a07e to 1af4627 Compare July 29, 2025 07:55
@Frando Frando requested a review from rklaehn July 29, 2025 07:57
@Frando Frando force-pushed the Frando/wrap-cleanup branch from 1af4627 to fcce583 Compare July 29, 2025 08:00
@Frando Frando changed the base branch from Frando/wrap to main July 29, 2025 08:00
let _: Token![,] = input.parse()?;
let arg: Ident = input.parse()?;
match arg.to_string().as_str() {
"derive" => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we just pass through all the things instead of specifically looking for derive(foo)? Maybe somebody wants to pass an attribute other than derive?

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's do this once the need arises, ok? Not passing through everything reserves us the chance to add more of our own attributes.

@rklaehn
Copy link
Collaborator

rklaehn commented Aug 5, 2025

I do like having wrap in a separate attribute.

Did we at some point have the option where the name of the struct is derived from the enum case? I seem to remember that, but maybe I was wrong. In any case, not sure if that is useful. Adding the name explicitly is probably less magic, which is good.

@Frando Frando merged commit f955176 into main Aug 11, 2025
16 checks passed
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