7 releases (breaking)

0.27.0 Oct 30, 2024
0.26.0 Sep 9, 2024
0.25.0 Aug 19, 2024
0.24.1 Aug 13, 2024
0.20.1 Mar 6, 2024

#1989 in Procedural macros

Download history 650/week @ 2024-07-26 973/week @ 2024-08-02 1448/week @ 2024-08-09 1119/week @ 2024-08-16 659/week @ 2024-08-23 873/week @ 2024-08-30 989/week @ 2024-09-06 291/week @ 2024-09-13 484/week @ 2024-09-20 214/week @ 2024-09-27 237/week @ 2024-10-04 267/week @ 2024-10-11 250/week @ 2024-10-18 321/week @ 2024-10-25 404/week @ 2024-11-01 141/week @ 2024-11-08

1,164 downloads per month
Used in 2 crates (via near-async)

MIT/Apache

22KB
371 lines

This crate provides a set of procedural macros for deriving traits for multi-sender types, which are structs that contain multiple Sender and AsyncSender fields. The structs can either have named fields or be a tuple struct.

The derive macros provided by this crate allows multi-senders to be created from anything that behaves like all of the individual senders, and allows the multi-sender to be used like any of the individual senders. This can be very useful when one component needs to send multiple kinds of messages to another component; for example the networking layer needs to send multiple types of messages to the ClientActor, each expecting a different response; it would be very cumbersome to have to construct the PeerManagerActor by passing in 10 different sender objects, so instead we create a multi-sender interface of all the senders and pass that in instead.

To better understand these macros,

  • Look at the tests in this crate for examples of what the macros generate.
  • Search for usages of the derive macros in the codebase.

Dependencies

~230–680KB
~16K SLoC