10 releases (breaking)

new 0.29.0 Feb 12, 2025
0.28.0 Dec 10, 2024
0.27.0 Oct 30, 2024
0.23.0 Jun 17, 2024
0.20.1 Mar 6, 2024

#1959 in Procedural macros

Download history 433/week @ 2024-10-29 248/week @ 2024-11-05 212/week @ 2024-11-12 134/week @ 2024-11-19 87/week @ 2024-11-26 110/week @ 2024-12-03 323/week @ 2024-12-10 144/week @ 2024-12-17 42/week @ 2024-12-24 71/week @ 2024-12-31 130/week @ 2025-01-07 177/week @ 2025-01-14 224/week @ 2025-01-21 73/week @ 2025-01-28 244/week @ 2025-02-04 289/week @ 2025-02-11

870 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

~205–640KB
~15K SLoC