Skip to content

Conversation

Frando
Copy link
Member

@Frando Frando commented Jul 21, 2025

Based on #47 (can rebase on main if needed)
Alternative to #41
Fixes #39

This PR tries to simplify working with irpc with these changes:

  • Added two associated types to the Service trait to point to the raw request enum (usually called XxxProtocol) and the message enum where the variants contain the WithChannels structs (usually called XxxMessage). By doing this, we can reduce the generics on the Client from 3 to 1, and on the LocalSender from 2 to 1. I think this is a net benefit for all users.

  • Instead of defining a separate Service struct, we can simply use the XxxProtocol struct as the service! One type less to define and manage.

  • The service trait is now implemented by the proc macro. It is still possible to set a service = SomeType arg if, for some reason, you'd want the service to be separate from the protocol enum type.

  • The proc macro's first and required argument is now the name of the message type. With the proc macro now implementing the serivce trait, and the service trait having an associated type for the message enum, I found it easiest to make the message enum creation non-optional. Also so far I never had a use case for the derive macro not creating the message enum. Do others? If not I think this is the simplest. Can also change it to be optional again though.

First and foremost, have a look at the diff to the examples.

@Frando Frando closed this Jul 21, 2025
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.

1 participant