You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: Add associated types to Service, use protocol enum as Service (#46)
This PR simplifies working with `irpc`:
* Instead of defining a separate `FooService` struct, the `Service` trait is implemented on the protocol enum. One type less to create.
* Added an associated types to the `Service` trait to point to the extended message enum (the one where the variants contain the `WithChannels` structs). 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.
* The service trait is now implemented by the proc macro if the `message` argument is provided.
* A new trait `RemoteService: Service` has a required method to create a a`Service::Message` from the protocol enum, and a provided method to create a `Handler` for use with the listen function. The `RemoteService` impl is generated by the proc macro. This saves the tedious manual impl of mapping from `msg, rx, tx` to the message enum (see the diff in the examples).
* Added `no_rpc` and `no_spans` arguments to the macro to omit generating code that depends on the `rpc` or `spans` features of `irpc`
* Expanded and improved the documentation of the `rpc_requests` macro. Also moved it from `irpc_derive` to `irpc` to be able to add doc links to items from `irpc`.
First and foremost, have a look at the diff to the examples.
0 commit comments